------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep/12-11-17_log.log
  log type:  text
 opened on:  17 Nov 2012, 14:04:40

. 
. ***Preparing
. *p4v2010_1.dta
. *gleditsch_dyad.dta
. *beck_webb1.dta
. *beck_webb2.dta
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. do "data_prep.do"

. *data_prep.do
. *File imported from here on May 28, 2012: http://www.systemicpeace.org/inscr/p4v2010.xls
. 
. clear

. *global filetree /Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep
. 
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. 
. set more off

. import excel "Other_files/p4v2010.xls", sheet("p4v2010") firstrow

. 
. order ccode year polity2

. sort ccode year

. keep ccode year polity2

. rename ccode ccode1

. sort ccode1 year

. save "Other_files/p4v2010_1.dta", replace
file Other_files/p4v2010_1.dta saved

. 
. rename ccode1 ccode2

. sort ccode2 year

. save "Other_files/p4v2010_2.dta", replace
file Other_files/p4v2010_2.dta saved

. clear

. 
. *Gleditsch Trade and GDP data
. clear

. *Downloaded from here: http://privatewww.essex.ac.uk/~ksg/exptradegdp.html
. insheet using "Other_files/exptradegdpv4.1 2/expdata.asc", delimiter(" ")
(23 vars, 579229 obs)

. rename numa ccode1

. rename numb ccode2

. order ccode1 ccode2 year rgdpca rgdpcb tottra tottrb popa popb

. keep ccode1 ccode2 year rgdpca rgdpcb tottra tottrb popa popb

. sort ccode1 ccode2 year

. save "Other_files/gleditsch_dyad.dta", replace
file Other_files/gleditsch_dyad.dta saved

. 
. *acra/b         Three letter acronym for state A/B      
. *numa/b         Numeric id code for state A/B
. *year           Year
. *expab          Export A to B
. *eabo           Export A to B origin code
. *impab          Import A from B
. *iabo           Import A from B origin code
. *expba          Export B to A           
. *ebao           Export B to A origin code
. *impba          Import B from A 
. *ibao           Import B from A origin code
. *popa           Population of A
. *rgdpca/b       Real GDP per capita of A/B
. *cgdpca/b       Current GDP per capita of A/B
. *goa/b          Origin of GDP per capita estimate A/B
. *tottra/b       Total trade for country A/B
. 
. 
. ****CIE data from Beck and Webb
. 
. 
. clear

. 
. **"data-wber.xls" provided to Allan Dafoe by Thorsten Beck on June 23, 2012. 
. *Another version of this file "beck_webb_original_data.xls" was found online at a link that is no longer live.
. 
. import excel "Other_files/data-wber.xls", sheet("panel") firstrow

. 
. *Count observations with lifepen coded
.  count if lifedeer~=.
  336

.  count if lifepen~=.
  334

.  *334
. 
. *Count countries with lifepen coded
. unique cc if lifepen~=.
Number of unique values of cc is  66
Number of records is  334

. *66
. 
. kountry cc, from(iso3c)

----------------------------------------
The command has finished.
The new variable is named NAMES_STD.
----------------------------------------

. rename NAMES_STD country_name1

.  
. kountry cc, from(iso3c) to(cown)

--------------------------------------------
You are converting from iso3c to cown....
--------------------------------------------

--------------------------------------
The command has finished.
The new variable is named _COWN_.
--------------------------------------

. rename _COWN_ ccode1

. 
. sort ccode1

. 
. 
. keep ccode1 period lifepen lifedens lifedeer acli lifeexp gdppc income country_name1 

. 
. *rename cc cc1
. rename period period1 

. rename lifepen lifepen1

. rename lifedens lifedens1

. rename acli acli1

. rename lifedeer lifedeer1

. rename lifeexp lifeexp1

. rename gdppc gdppc1

. rename income income1

. sort ccode1

. 
. *creating country-year data
. expand 5
(2208 observations created)

. 
. sort ccode1 period

. 
. by ccode1: gen year1=1960+_n

. *Beck and Webb's excel file states that period 1 covers 1961-1965, period 2 1966-1970, etc...
. 
. sort ccode1 year1

. 
. 
. save "beck_webb1.dta", replace
file beck_webb1.dta saved

. 
. rename year1 year2

. rename period1 period2

. rename lifepen1 lifepen2

. rename income1 income2

. rename lifedens1 lifedens2

. rename lifedeer1 lifedeer2

. rename lifeexp1 lifeexp2

. rename acli acli2

. rename gdppc1 gdppc2

. rename country_name1 country_name2

. rename ccode1 ccode2

. 
. sort ccode2 year2

. save "beck_webb2.dta", replace
file beck_webb2.dta saved

. 
. clear

. 
end of do-file

. 
. *Produces 
. *"12-06-13_mids.dta"
. *"12-05-28_dem_CIE_analysis.dta"
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. do "AD_data_merge.do"

. *12-06-23_AD_data_merge.do
. clear

. 
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. 
. **Run initial EUGene do file
. do "12-05-28_dyad.out.do"

. * STATA command file generated by EUGene  3.20 to read data file
. * "\\psf\Home\Documents\EUGene_Output\12-05-28_dyad.out"
. * To execute this command file: 
. *    1) Run STATA,
. *    2) "cd" to directory "\\psf\Home\Documents\EUGene_Output\",
. *    3) enter command "do 12-05-28_dyad.out.do".
. 
. * Number of observations in this data set: 805239
. 
. * Data set specifications:
. *   Base Format: Non-directed Dyad
. *   Time Span: 1816 to 2008
. *   Selected Subset: All dyads included)
. *   Sampling: None (100% of available data written to file)
. *   Variables included:
. *        ccode1 ccode2  year    abbrev1 abbrev2 cap_1   cap_2   milper_1        milex_1 energy_1        irst_1  upop_1  tpop_1  milper_2
>         milex_2 energy_2        irst_2  upop_2  tpop_2  majpow1 majpow2 rlreg12 rlreg21 contig  distance        numstate        numGPs  
> cwongo  cwongonm        cwmid   cwmidnm cwdynm  cwhost1 cwhost2 cwhostd cwkeynum        cworig1 cworig2 cwmidnme        cwstmo1 cwstday1
>         cwstyr1 cwstmo2 cwstday2        cwstyr2 cwendmo1        cwenddy1        cwendyr1        cwendmo2        cwenddy2        cwendyr2
>         cwrevt11        cwrevt21        cwrevt12        cwrevt22        cwfatal1        cwfatex1        cwfatal2        cwfatex2        
> cwhiact1        cwhiact2        cwhiactd        cwoutcm cwsettle        cwfatald        cwrecip cwnumst1        cwnumst2        cwpceyrs
>         democ1  democ2  autoc1  autoc2  polity1 polity2 polity21        polity22
. *   Selected settings for variables with multiple output options:
. *        Distance variable measured using capitol coordinates and land contiguity, including modifications from The War Trap
. *        Peace years calculated using Werner peace year adjustment
. *       Dispute characteristics:
. *        When two or more disputes occur in a year, data is from the highest intensity dispute
. *        Disputes marked for originators only
. *        All dyad-years with an ongoing MID dropped
. *        Ongoing dispute years not considered new initiations
. *        Joiner Dyads included
. 
. * Note:  EUGene draws on datasets originally published elsewhere by other scholars.  When 
. * presenting analysis using data generated by EUGene, please cite the original data sources 
. * as well as EUGene (see EUGene documentation, Appendix D) 
. *
. * Bibliography for this data set:
. * Beck, Nathaniel, Jonathan Katz, and Richard Tucker.  1997.  "Taking Time Seriously:  Time-Series - Cross-Section Analysis with a Binar
> y Dependent Variable."  American Journal of Political Science 42 (October); 1260-1288.
. * Bueno de Mesquita, Bruce.  1981.  The War Trap.  New Haven: Yale University Press.
. * Jones, Daniel M., Stuart A. Bremer and J. David Singer 1996.  "Militarized Interstate Disputes, 1816-1992: Rationale, Coding Rules, an
> d Empirical Patterns."          Conflict Management and Peace Science 15(2); 163:213.
. * Small, Melvin, and J. David Singer.  1969.  "Formal Alliances, 1815-1965:  An Extension of the Basic Data."  Journal of Peace Research
>  6: 257-282.  
. * Werner, Suzanne.  2000.  "The Effects of Political Similarity on the Onset of Militarized Disputes, 1816-1985."  Political Research Qu
> arterly 53(2): 343-374.
. * 
. * 
. * Marshall, Monty G. and Keith Jaggers. 2002. Polity IV Project: Political Regime Characteristics and Transitions, 1800-2002. http://www
> .cidcm.umd.edu/inscr/polity/index.htm.
. 
. #delimit ;
delimiter now ;
. clear;

. set memory 268421k;
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. infile int ccode1 int ccode2 int year str3 abbrev1 str3 abbrev2 float cap_1 float cap_2 float milper_1 float milex_1 float energy_1 floa
> t irst_1 float upop_1 float tpop_1 float milper_2 float milex_2 float energy_2 float irst_2 float upop_2 float tpop_2 byte majpow1 byte 
> majpow2 byte rlreg12 byte rlreg21 byte contig float distance int numstate int numGPs int cwongo int cwongonm int cwmid int cwmidnm int c
> wdynm int cwhost1 int cwhost2 byte cwhostd int cwkeynum byte cworig1 byte cworig2 str40 cwmidnme int cwstmo1 int cwstday1 int cwstyr1 in
> t cwstmo2 int cwstday2 int cwstyr2 int cwendmo1 int cwenddy1 int cwendyr1 int cwendmo2 int cwenddy2 int cwendyr2 byte cwrevt11 byte cwre
> vt21 byte cwrevt12 byte cwrevt22 int cwfatal1 int cwfatex1 int cwfatal2 int cwfatex2 byte cwhiact1 byte cwhiact2 byte cwhiactd byte cwou
> tcm byte cwsettle int cwfatald byte cwrecip int cwnumst1 int cwnumst2 int cwpceyrs long democ1 long democ2 long autoc1 long autoc2 long 
> polity1 long polity2 long polity21 long polity22  using "12-05-28_dyad.out";
'ccode1' cannot be read as a number for ccode1[1]
'ccode2' cannot be read as a number for ccode2[1]
'year' cannot be read as a number for year[1]
'cap_1' cannot be read as a number for cap_1[1]
'cap_2' cannot be read as a number for cap_2[1]
'milper_1' cannot be read as a number for milper_1[1]
'milex_1' cannot be read as a number for milex_1[1]
'energy_1' cannot be read as a number for energy_1[1]
'irst_1' cannot be read as a number for irst_1[1]
'upop_1' cannot be read as a number for upop_1[1]
'tpop_1' cannot be read as a number for tpop_1[1]
'milper_2' cannot be read as a number for milper_2[1]
'milex_2' cannot be read as a number for milex_2[1]
'energy_2' cannot be read as a number for energy_2[1]
'irst_2' cannot be read as a number for irst_2[1]
'upop_2' cannot be read as a number for upop_2[1]
'tpop_2' cannot be read as a number for tpop_2[1]
'majpow1' cannot be read as a number for majpow1[1]
'majpow2' cannot be read as a number for majpow2[1]
'rlreg12' cannot be read as a number for rlreg12[1]
'rlreg21' cannot be read as a number for rlreg21[1]
'contig' cannot be read as a number for contig[1]
'distance' cannot be read as a number for distance[1]
'numstate' cannot be read as a number for numstate[1]
'numGPs' cannot be read as a number for numGPs[1]
'cwongo' cannot be read as a number for cwongo[1]
'cwongonm' cannot be read as a number for cwongonm[1]
'cwmid' cannot be read as a number for cwmid[1]
'cwmidnm' cannot be read as a number for cwmidnm[1]
'cwdynm' cannot be read as a number for cwdynm[1]
'cwhost1' cannot be read as a number for cwhost1[1]
'cwhost2' cannot be read as a number for cwhost2[1]
'cwhostd' cannot be read as a number for cwhostd[1]
'cwkeynum' cannot be read as a number for cwkeynum[1]
'cworig1' cannot be read as a number for cworig1[1]
'cworig2' cannot be read as a number for cworig2[1]
'cwstmo1' cannot be read as a number for cwstmo1[1]
'cwstday1' cannot be read as a number for cwstday1[1]
'cwstyr1' cannot be read as a number for cwstyr1[1]
'cwstmo2' cannot be read as a number for cwstmo2[1]
'cwstday2' cannot be read as a number for cwstday2[1]
'cwstyr2' cannot be read as a number for cwstyr2[1]
'cwendmo1' cannot be read as a number for cwendmo1[1]
'cwenddy1' cannot be read as a number for cwenddy1[1]
'cwendyr1' cannot be read as a number for cwendyr1[1]
'cwendmo2' cannot be read as a number for cwendmo2[1]
'cwenddy2' cannot be read as a number for cwenddy2[1]
'cwendyr2' cannot be read as a number for cwendyr2[1]
'cwrevt11' cannot be read as a number for cwrevt11[1]
'cwrevt21' cannot be read as a number for cwrevt21[1]
'cwrevt12' cannot be read as a number for cwrevt12[1]
'cwrevt22' cannot be read as a number for cwrevt22[1]
'cwfatal1' cannot be read as a number for cwfatal1[1]
'cwfatex1' cannot be read as a number for cwfatex1[1]
'cwfatal2' cannot be read as a number for cwfatal2[1]
'cwfatex2' cannot be read as a number for cwfatex2[1]
'cwhiact1' cannot be read as a number for cwhiact1[1]
'cwhiact2' cannot be read as a number for cwhiact2[1]
'cwhiactd' cannot be read as a number for cwhiactd[1]
'cwoutcm' cannot be read as a number for cwoutcm[1]
'cwsettle' cannot be read as a number for cwsettle[1]
'cwfatald' cannot be read as a number for cwfatald[1]
'cwrecip' cannot be read as a number for cwrecip[1]
'cwnumst1' cannot be read as a number for cwnumst1[1]
'cwnumst2' cannot be read as a number for cwnumst2[1]
'cwpceyrs' cannot be read as a number for cwpceyrs[1]
'democ1' cannot be read as a number for democ1[1]
'democ2' cannot be read as a number for democ2[1]
'autoc1' cannot be read as a number for autoc1[1]
'autoc2' cannot be read as a number for autoc2[1]
'polity1' cannot be read as a number for polity1[1]
'polity2' cannot be read as a number for polity2[1]
'polity21' cannot be read as a number for polity21[1]
'polity22' cannot be read as a number for polity22[1]
(805240 observations read)

. * The next command drops the case that was read 
> *  if the user included a line of variable names;
. drop if missing(ccode1) | missing(year);
(1 observation deleted)

. * Interpret missing values;
.  mvdecode ccode1 ccode2 year abbrev1 abbrev2 cap_1 cap_2 milper_1 milex_1 energy_1 irst_1 upop_1 tpop_1 milper_2 milex_2 energy_2 irst_2
>  upop_2 tpop_2 majpow1 majpow2 rlreg12 rlreg21 contig distance numstate numGPs cwongo cwongonm cwmid cwmidnm cwdynm cwhost1 cwhost2 cwho
> std cwkeynum cworig1 cworig2 cwmidnme cwstmo1 cwstday1 cwstyr1 cwstmo2 cwstday2 cwstyr2 cwendmo1 cwenddy1 cwendyr1 cwendmo2 cwenddy2 cwe
> ndyr2 cwrevt11 cwrevt21 cwrevt12 cwrevt22 cwfatal1 cwfatex1 cwfatal2 cwfatex2 cwhiact1 cwhiact2 cwhiactd cwoutcm cwsettle cwfatald cwrec
> ip cwnumst1 cwnumst2 cwpceyrs , mv(-9);
     abbrev1: string variable ignored
     abbrev2: string variable ignored
       cap_1: 18721 missing values generated
       cap_2: 18721 missing values generated
    milper_1: 34181 missing values generated
     milex_1: 80169 missing values generated
    energy_1: 23952 missing values generated
      irst_1: 26390 missing values generated
      upop_1: 19150 missing values generated
      tpop_1: 19595 missing values generated
    milper_2: 37464 missing values generated
     milex_2: 90356 missing values generated
    energy_2: 28369 missing values generated
      irst_2: 23877 missing values generated
      upop_2: 21508 missing values generated
      tpop_2: 19143 missing values generated
      contig: 110785 missing values generated
      cwongo: 129121 missing values generated
    cwongonm: 129121 missing values generated
       cwmid: 129121 missing values generated
     cwmidnm: 129121 missing values generated
      cwdynm: 129121 missing values generated
     cwhost1: 129121 missing values generated
     cwhost2: 129121 missing values generated
     cwhostd: 129121 missing values generated
    cwkeynum: 129121 missing values generated
     cworig1: 129121 missing values generated
     cworig2: 129121 missing values generated
    cwmidnme: string variable ignored
     cwstmo1: 129121 missing values generated
    cwstday1: 129602 missing values generated
     cwstyr1: 129121 missing values generated
     cwstmo2: 129121 missing values generated
    cwstday2: 129602 missing values generated
     cwstyr2: 129121 missing values generated
    cwendmo1: 129121 missing values generated
    cwenddy1: 129613 missing values generated
    cwendyr1: 129121 missing values generated
    cwendmo2: 129121 missing values generated
    cwenddy2: 129613 missing values generated
    cwendyr2: 129121 missing values generated
    cwrevt11: 129121 missing values generated
    cwrevt21: 133196 missing values generated
    cwrevt12: 129121 missing values generated
    cwrevt22: 133196 missing values generated
    cwfatal1: 129748 missing values generated
    cwfatex1: 131251 missing values generated
    cwfatal2: 129733 missing values generated
    cwfatex2: 131334 missing values generated
    cwhiact1: 129121 missing values generated
    cwhiact2: 129121 missing values generated
    cwhiactd: 129121 missing values generated
     cwoutcm: 129121 missing values generated
    cwsettle: 129121 missing values generated
    cwfatald: 129735 missing values generated
     cwrecip: 129121 missing values generated
    cwnumst1: 129121 missing values generated
    cwnumst2: 129121 missing values generated
    cwpceyrs: 129121 missing values generated

. mvdecode democ1, mv(-99);
      democ1: 155492 missing values generated

. mvdecode democ2, mv(-99);
      democ2: 133345 missing values generated

. mvdecode autoc1, mv(-99);
      autoc1: 155492 missing values generated

. mvdecode autoc2, mv(-99);
      autoc2: 133345 missing values generated

. mvdecode polity1, mv(-99);
     polity1: 155492 missing values generated

. mvdecode polity2, mv(-99);
     polity2: 133345 missing values generated

. mvdecode polity21, mv(-99);
    polity21: 160589 missing values generated

. mvdecode polity22, mv(-99);
    polity22: 141225 missing values generated

. * Variable labels where available (see EUGeneDocumentation.doc for full information);
.  label variable ccode1 "COW CCode Num for state 1";

. label variable ccode2 "COW CCode Num for state 2";

. label variable year "Year of observation";

. label variable abbrev1 "Country Abbreviation state 1";

. label variable abbrev2 "Country Abbreviation state 2";

. label variable cap_1 "National Capabilities Index (CINC) for cc1";

. label variable cap_2 "National Capabilities Index (CINC) for cc2";

. label variable milper_1 "COW military personnel for cc1";

. label variable milex_1 "COW military expenditure for cc1";

. label variable energy_1 "COW energy production for cc1";

. label variable irst_1 "COW iron/steel production for cc1";

. label variable upop_1 "COW nominal urban population for cc1";

. label variable tpop_1 "COW nominal total population for cc1";

. label variable milper_2 "COW military personnel for cc2";

. label variable milex_2 "COW military expenditure for cc2";

. label variable energy_2 "COW energy production for cc2";

. label variable irst_2 "COW iron/steel production for cc2";

. label variable upop_2 "COW nominal urban population for cc2";

. label variable tpop_2 "COW nominal total population for cc2";

. label variable majpow1 "Major power status of cc1";

. label variable majpow2 "Major power status of cc2";

. label variable rlreg12 "Region relevant to Directed Dyad cc1 vs. cc2";

. label variable rlreg21 "Region relevant to Directed Dyad cc2 vs. cc1";

. label variable contig "Direct contig (1=Lnd, 2=1-12 miles watr, 3=13-24, 4=25-150, 5=151-400, 6=not)";

. label variable distance "Distance, from cc1 to cc2, in miles";

. label variable numstate "Number of states in intl system as defined by COW system membership";

. label variable numGPs "Num of great powers in the international system";

. label variable cwongo "A MID was ongoing at the beginning of this year, COW MID data";

. label variable cwongonm "Num of the MID that was ongoing at the beginning of the year, if any";

. label variable cwmid "MID Onset:  A MID occurred betw cc1 and cc2 in year (0=no, 1=yes).  ";

. label variable cwmidnm "Num of the new MID that began in this year, if any;  marks dispute ONSET";

. label variable cwdynm "Dyadic MID number (new number for each dyad-episode within each MID)";

. label variable cwhost1 "Relevant hostility level reached by cc1 in a MID vs. cc2 in this year";

. label variable cwhost2 "Relevant hostility level reached by cc2 in a MID vs. cc1 in this year";

. label variable cwhostd "Overall dispute hostility level (0 to 5, as in hostlev1)";

. label variable cwkeynum "Key MID number: Num of MID for which other MID variables are reported.  ";

. label variable cworig1 "cc1 is originator of the key MID, i.e. is involved on first day (0=no, 1=yes)";

. label variable cworig2 "cc2 is originator of the key MID (0=no, 1=yes)";

. label variable cwmidnme "Name of the MID identified in cwkeynum, if one has been designated by COW.";

. label variable cwstmo1 "MID start month for cc1";

. label variable cwstday1 "MID start day for cc1";

. label variable cwstyr1 "MID start year for cc1";

. label variable cwstmo2 "MID start month for cc2";

. label variable cwstday2 "MID start day for cc2";

. label variable cwstyr2 "MID start year for cc2";

. label variable cwendmo1 "MID end month for cc1";

. label variable cwenddy1 "MID end day for cc1";

. label variable cwendyr1 "MID end year for cc1";

. label variable cwendmo2 "MID end month for cc2";

. label variable cwenddy2 "MID end day for cc2";

. label variable cwendyr2 "MID end year for cc2";

. label variable cwrevt11 "Revision Type 1 for CCode1 (0=n/a, 1=territory, 2=policy, 3=regime, 4=other)";

. label variable cwrevt21 "Revision Type 2, State 1, when present in COW v3.0 data (missing pre 1992)";

. label variable cwrevt12 "Revision Type 1, State 2";

. label variable cwrevt22 "Revision Type 2, State 2, when present in COW v3.0 data.";

. label variable cwfatal1 "Fatality level for cc1";

. label variable cwfatex1 "Exact estimate of fatalities for cc1, if estimated in MID v3.0.";

. label variable cwfatal2 "Fatality level for cc2 (0 to 6, as in fatal1)";

. label variable cwfatex2 "Exact estimate of fatalities for cc2, if estimated in MID v3.0.";

. label variable cwhiact1 "Highest action by cc1 in dispute (see MID B codebook)";

. label variable cwhiact2 "Highest action by cc2 in dispute (see MID B codebook)";

. label variable cwhiactd "Highest action in dispute (see MID A codebook)";

. label variable cwoutcm "Overall dispute outcome (see MID A codebook)";

. label variable cwsettle "Overall MID settlement (1=negotiated, 2=imposed, 3=none, 4=unclear, -9=missing)";

. label variable cwfatald "Overall dispute fatality level (cow data)";

. label variable cwrecip "Reciprocated dispute (0=no, 1=yes)";

. label variable cwnumst1 "Num of states on cc1s side";

. label variable cwnumst2 "Num of states on cc2s side";

. label variable cwpceyrs "Peace Years, based on MIDs occurrence in COW dyadic MID set";

. compress;
milper_1 was float now int
milper_2 was float now int
distance was float now int
numGPs was int now byte
cwongo was int now byte
cwmid was int now byte
cwhost1 was int now byte
cwhost2 was int now byte
cwstmo1 was int now byte
cwstday1 was int now byte
cwstmo2 was int now byte
cwstday2 was int now byte
cwendmo1 was int now byte
cwenddy1 was int now byte
cwendmo2 was int now byte
cwenddy2 was int now byte
cwfatal1 was int now byte
cwfatex1 was int now byte
cwfatal2 was int now byte
cwfatex2 was int now byte
cwfatald was int now byte
cwnumst1 was int now byte
cwnumst2 was int now byte
democ1 was long now byte
democ2 was long now byte
autoc1 was long now byte
autoc2 was long now byte
polity1 was long now byte
polity2 was long now byte
polity21 was long now byte
polity22 was long now byte

. 
end of do-file

. *Note: the do file says that ongoing disputes are dropped, but I set EUGene to have "No Exclusions" and there are ongoing MIDs (cwongo) 
> in the dataset, so this must be a typo. 
. 
. order ccode1 ccode2 year abbrev1 abbrev2 cwmid cwongo cwfatald polity21 polity22

. 
. *Dyadic Democracy Variables
. g dml=min(polity21, polity22) if polity21~=. & polity22~=.
(217644 missing values generated)

. label variable dml "DemocracyLow"

. g dmh=max(polity21, polity22) if polity21~=. & polity22~=.
(217644 missing values generated)

. label variable dmh "DemocracyHigh"

. 
. g mjpw=max(majpow1, majpow2) if majpow1~=. & majpow2~=.

. label variable mjpw "Major power"

. 
. 
. *contigl defined as contiguity by land
. g contigl=0 if contig~=1 & contig~=.
(130812 missing values generated)

. replace contigl=1 if contig==1
(20027 real changes made)

. label variable contigl "Land Contiguity"

. 
. 
. gen lndist=log(distance)
(20027 missing values generated)

. 
. g cpl = cap_1 if cap_1 < cap_2 & cap_1~=. & cap_2~=.
(386134 missing values generated)

. replace cpl = cap_2 if cap_2 <= cap_1 & cap_1~=. & cap_2~=.
(367413 real changes made)

. g cph = cap_1 if cap_1 > cap_2 & cap_1~=. & cap_2~=.
(438591 missing values generated)

. replace cph = cap_2 if cap_2 >= cap_1 & cap_1~=. & cap_2~=.
(419870 real changes made)

. g lncprt=ln(cph/cpl) if cph~=. & cpl~=.
(21958 missing values generated)

. *drop cap_1 cap_2 cpl cph
. label variable lncprt "Relative capability"

. 
. *calculate probability of winning using CINCs*
. gen pwin_cap=cph/(cph+cpl)
(18729 missing values generated)

. 
. gen dyadid=(ccode1*1000)+ccode2

. 
. sort ccode1 ccode2 year

. order ccode1 ccode2 year abbrev1 abbrev2 cwmid cwongo cwfatald dyadid pwin_cap lncprt mjpw dml dmh contigl lndist

. save "12-05-28_dem_CIE_analysis.dta", replace
file 12-05-28_dem_CIE_analysis.dta saved

. 
. 
. *sort ccode1 ccode2 year
. *sort ccode1 year
. *merge m:1 ccode1 year using "Other_files/p4v2010_1.dta"
. *tab polity21 polity1
. **confirmed: the polity4 variables provided by EUGene are up to date
. 
. **Dependent Variables
. sort dyadid year

. sort dyadid

. by dyadid: gen midonsl=cwmid[_n+1] 
(148973 missing values generated)

. by dyadid: replace midonsl=. if cwongo[_n+1]==1
(1727 real changes made, 1727 to missing)

. label variable midonsl "MID onset lead"

. 
. sort dyadid year

. sort dyadid

. by dyadid: gen midongl=cwongo[_n+1] 
(148973 missing values generated)

. by dyadid: replace midongl=1 if cwmid[_n+1]==1
(2237 real changes made)

. label variable midongl "MID ongoing lead"

. 
. sort dyadid year

. sort dyadid

. by dyadid: gen fmidonsl=1 if midonsl==1 & cwfatald[_n+1]>0 & cwfatald[_n+1]~=.
(804866 missing values generated)

. by dyadid: replace fmidonsl=0 if midonsl==0 | cwfatald[_n+1]==0 
(654357 real changes made)

. replace fmidonsl=. if cwongo[_n+1]==1
(449 real changes made, 449 to missing)

. label variable fmidons "Fatal MID onset lead"

. 
. sort dyadid year

. sort dyadid

. by dyadid: gen fmidongl=1 if midongl==1 & cwfatald[_n+1]>0 & cwfatald[_n+1]~=.
(803834 missing values generated)

. by dyadid: replace fmidongl=0 if midongl==0 | cwfatald[_n+1]==0 
(654357 real changes made)

. label variable fmidongl "Fatal MID ongoing lead"

. 
. sort dyadid year

. sort dyadid

. by dyadid: gen warl=1 if midongl==1 & cwfatald[_n+1]==6
(804324 missing values generated)

. by dyadid: replace warl=0 if midongl==0 | cwfatald[_n+1]<6 
(654847 real changes made)

. label variable warl "War onset or ongoing lead"

. 
.  tab midonsl midongl, m

 MID onset |         MID ongoing lead
      lead |         0          1          . |     Total
-----------+---------------------------------+----------
         0 |   652,302          0          0 |   652,302 
         1 |         0      2,237          0 |     2,237 
         . |         0      1,727    148,973 |   150,700 
-----------+---------------------------------+----------
     Total |   652,302      3,964    148,973 |   805,239 


.   tab fmidonsl fmidongl, m

 Fatal MID |      Fatal MID ongoing lead
onset lead |         0          1          . |     Total
-----------+---------------------------------+----------
         0 |   653,908          0          0 |   653,908 
         1 |         0        373          0 |       373 
         . |       449      1,032    149,477 |   150,958 
-----------+---------------------------------+----------
     Total |   654,357      1,405    149,477 |   805,239 


.   *AD: 449 fmidongl=0 are missing for fmidonsl (these are probably ongoing MIDs)
.   tab warl fmidongl, m

 War onset |
or ongoing |      Fatal MID ongoing lead
      lead |         0          1          . |     Total
-----------+---------------------------------+----------
         0 |   654,357        490          0 |   654,847 
         1 |         0        915          0 |       915 
         . |         0          0    149,477 |   149,477 
-----------+---------------------------------+----------
     Total |   654,357      1,405    149,477 |   805,239 


. 
. ***Peace-years
. 
. btscs midongl year dyadid, g(midyears)

. gen midyears2=midyears^2
(148973 missing values generated)

. gen midyears3=midyears^3
(148973 missing values generated)

. 
. btscs fmidongl year dyadid, g(fmidyears)

. gen fmidyears2=fmidyears^2
(149477 missing values generated)

. gen fmidyears3=fmidyears^3
(149477 missing values generated)

. 
. btscs warl year dyad, g(waryears)

. gen waryears2=waryears^2
(149477 missing values generated)

. gen waryears3=waryears^3
(149477 missing values generated)

. 
. 
. kountry ccode1, from(cown)

----------------------------------------
The command has finished.
The new variable is named NAMES_STD.
----------------------------------------

. rename NAMES_STD country_name1

.  
. kountry ccode2, from(cown) 

----------------------------------------
The command has finished.
The new variable is named NAMES_STD.
----------------------------------------

. rename NAMES_STD country_name2

. 
. order country_name*

. save "12-05-28_dem_CIE_analysis.dta", replace
file 12-05-28_dem_CIE_analysis.dta saved

. 
. keep ccode1 ccode2 year polity21 polity22 midonsl midongl fmidonsl fmidongl warl midyears midyears2 midyears3 fmidyears fmidyears2 fmidy
> ears3 waryears waryears2 waryears3 cwmidnm cwongonm

. 
. sort ccode1 ccode2 year

. save "12-06-13_mids.dta", replace
file 12-06-13_mids.dta saved

. clear

. 
. 
. use  "12-05-28_dem_CIE_analysis.dta"

. 
. **Merging:  CIEl (CIEh) (dmlCIEh) (lifepen) (gdppc)
. 
. sort ccode1 ccode2 year

. 
. rename year year1

. sort ccode1 year1

. 
. merge m:1 ccode1 year1 using "beck_webb1.dta"
year1 was int now float

    Result                           # of obs.
    -----------------------------------------
    not matched                       589,203
        from master                   588,962  (_merge==1)
        from using                        241  (_merge==2)

    matched                           216,277  (_merge==3)
    -----------------------------------------

. keep if _merge==3 | _merge==1
(241 observations deleted)

. drop _merge

. 
. 
. rename year1 year2

. sort ccode2 year2

. 
. merge m:1 ccode2 year2 using "beck_webb2.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                       629,253
        from master                   628,987  (_merge==1)
        from using                        266  (_merge==2)

    matched                           176,252  (_merge==3)
    -----------------------------------------

. keep if _merge==3 | _merge==1
(266 observations deleted)

. drop _merge

. 
. rename year2 year

. 
. gen CIEnl=log(min(lifedeer1, lifedeer2))  if lifedeer1~=. & lifedeer2~=.
(766234 missing values generated)

. gen CIEnh=log(max(lifedeer1, lifedeer2))  if lifedeer1~=. & lifedeer2~=.
(766234 missing values generated)

. 
. 
. *set up sample
. count if CIEnl==. & midongl~=. & ccode1~=. & ccode2~=. & year>1950
485157

. local A1= r(N)

. count if midongl~=. & ccode1~=. & ccode2~=. & year>1950
524162

. local A2= r(N)

. di `A1'/`A2'
.92558598

. *93% of the sample involves missing values of CIEl as generated from Beck and Webb's data! 
. 
. gen lifepenl=log(min(lifepen1, lifepen2))  if lifepen1~=. & lifepen2~=.
(766674 missing values generated)

. gen lifedensl=log(min(lifedens1, lifedens2))  if lifedens1~=. & lifedens2~=.
(767764 missing values generated)

. gen lifeexpl=log(min(lifeexp1, lifeexp2))  if lifeexp1~=. & lifeexp2~=.
(726129 missing values generated)

. gen aclil=log(min(acli1, acli2))  if acli1~=. & acli2~=.
(787466 missing values generated)

. 
. *keep if ccode1~=. & ccode2~=. & year>1950 & polity21~=. & polity22~=.
. 
. 
. **Merge original Gleditsch files
. sort ccode1 ccode2 year

. merge 1:1 ccode1 ccode2 year using "Other_files/gleditsch_dyad.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                       336,440
        from master                   281,225  (_merge==1)
        from using                     55,215  (_merge==2)

    matched                           524,014  (_merge==3)
    -----------------------------------------

. drop if  _merge==2
(55215 observations deleted)

. 
. drop  _merge

. 
. gen rgdpcl=min(rgdpca,rgdpcb) if rgdpca~=. & rgdpcb~=.
(286556 missing values generated)

. 
. corr rgdpcl CIEnl
(obs=38330)

             |   rgdpcl    CIEnl
-------------+------------------
      rgdpcl |   1.0000
       CIEnl |   0.8158   1.0000


. *0.84 
. count if rgdpcl==. & midongl~=. & ccode1~=. & ccode2~=. & year>1950
 9339

. local A1= r(N)

. count if midongl~=. & ccode1~=. & ccode2~=. & year>1950
524162

. local A2= r(N)

. di `A1'/`A2'
.01781701

. *2% of the sample involves missing values of rgdppc!!
. 
. order dyadid year midongl midonsl fmidonsl fmidongl warl abbrev1 abbrev2 dml CIEnl CIEnh rgdpcl mjpw dmh contig lndist lifepenl lifedens
> l aclil lifeexpl country_name1 country_name2 ccode1 ccode2 cwmid cwongo cwfatald pwin_cap lncprt contigl polity21 polity22 cap_1 cap_2 m
> ilper_1 milex_1 energy_1 irst_1 upop_1 tpop_1 milper_2 milex_2 energy_2 irst_2 upop_2 tpop_2 majpow1 majpow2 rlreg12 rlreg21 distance cp
> l cph rgdpca rgdpcb tottra tottrb popa popb lifepen1 acli1 income1 lifedens1 lifedeer1 lifeexp1 period2 lifepen2 acli2 income2 lifedens2
>  lifedeer2 lifeexp2 

. 
. keep dyadid year midongl midonsl fmidonsl fmidongl warl abbrev1 abbrev2 dml CIEnl CIEnh rgdpcl mjpw dmh contig lndist lifepenl lifedensl
>  lifeexpl aclil country_name1 country_name2 ccode1 ccode2 cwmid cwongo cwfatald pwin_cap lncprt contigl polity21 polity22 cap_1 cap_2 mi
> lper_1 milex_1 energy_1 irst_1 upop_1 tpop_1 milper_2 milex_2 energy_2 irst_2 upop_2 tpop_2 majpow1 majpow2 rlreg12 rlreg21 distance cpl
>  cph rgdpca rgdpcb tottra tottrb popa popb lifepen1 acli1 income1 lifedens1 lifedeer1 lifeexp1 period2 lifepen2 acli2 income2 lifedens2 
> lifedeer2 lifeexp2 

. 
. sort dyadid year

. 
. keep if midongl~=. & ccode1~=. & ccode2~=. & year>1950 & dml~=.
(384141 observations deleted)

. 
. tab country_name1 if polity21==., sort
no observations

. tab country_name2 if polity22==., sort
no observations

. *Therefore, missing values on polity correspond to mostly small countries: Maldives, Samoa, Vanuatu, Iceland, Sychelles, Brunei, etc... 
> I now drop them.
. 
. drop if dml==.
(0 observations deleted)

. 
. 
. save "12-05-28_dem_CIE_analysis.dta", replace
file 12-05-28_dem_CIE_analysis.dta saved

. saveold "12-05-28_dem_CIE_analysis2.dta", replace
file 12-05-28_dem_CIE_analysis2.dta saved

. 
end of do-file

. 
. 
. ***Analysis of Beck and Webb, and Maoz MID data***
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. do "12-06-23_beck_webb_analysis.do"

. ***Analyze Beck and Webb data***
. **Beck and Webb data "data-wber.xls" was provided by Thorsten Beck on June 23, 2012. 
. **Thorsten Beck recommended SwissRe for the best data on life insurance, though this is not publicly available: http://www.swissre.com/s
> igma/Data_selling.html
. 
. clear

. use "beck_webb1.dta"

. 
. kountry ccode1, from(cown) to(cowc)

--------------------------------------------
You are converting from cown to cowc....
--------------------------------------------

--------------------------------------
The command has finished.
The new variable is named _COWC_.
--------------------------------------

. rename _COWC_ abbrev

. 
. gen lnlifedeer=log(lifedeer1)
(1080 missing values generated)

. gen lngdppc=log(gdppc1)
(160 missing values generated)

. corr lngdppc lnlifedeer
(obs=1670)

             |  lngdppc lnlife~r
-------------+------------------
     lngdppc |   1.0000
  lnlifedeer |   0.8648   1.0000


. 
. *r=0.86
. 
. ****Examining DVs used by Mousseau 2013: mzongo and mzmid****
. 
. clear

. cd "$filetree/Eugene"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep/Eugene

. ** "dyad_year_origonly.out.do" is the do file provided by EUGene which generates a dataset of non-directed dyad years, counting originat
> ors only for MIDs
. do "dyad_year_origonly.out.do"

. * STATA command file generated by EUGene  3.20 to read data file
. * "C:\Program Files\EUGene\dyad_year_origonly.out"
. * To execute this command file: 
. *    1) Run STATA,
. *    2) "cd" to directory "C:\Program Files\EUGene\",
. *    3) enter command "do dyad_year_origonly.out.do".
. 
. * Number of observations in this data set: 805239
. 
. * Data set specifications:
. *   Base Format: Non-directed Dyad
. *   Time Span: 1816 to 2008
. *   Selected Subset: All dyads included)
. *   Sampling: None (100% of available data written to file)
. *   Variables included:
. *        ccode1 ccode2  year    cwongo  cwongonm        cwmid   cwmidnm cwdynm  cwhost1 cwhost2 cwkeynum        cwjoany cwjomid cwfatald
>         mzongo  mzongonm        mzmid   mzmidnm mzhost1 mzhost2 mzkeynum        mzjoany mzjomid mzfatald
. *   Selected settings for variables with multiple output options:
. *        Peace years calculated without Werner peace year adjustment
. *       Dispute characteristics:
. *        When two or more disputes occur in a year, data is from the highest intensity dispute
. *        Disputes marked for originators only
. *        All dyad-years with an ongoing MID dropped
. *        Ongoing dispute years not considered new initiations
. *        Joiner Dyads included
. 
. * Note:  EUGene draws on datasets originally published elsewhere by other scholars.  When 
. * presenting analysis using data generated by EUGene, please cite the original data sources 
. * as well as EUGene (see EUGene documentation, Appendix D) 
. *
. * Bibliography for this data set:
. * Jones, Daniel M., Stuart A. Bremer and J. David Singer 1996.  "Militarized Interstate Disputes, 1816-1992: Rationale, Coding Rules, an
> d Empirical Patterns."          Conflict Management and Peace Science 15(2); 163:213.
. * Maoz, Zeev.  1999.  "Dyadic Militarized Interstate Disputes, version 1.1."  Available at ftp://spirit.tau.ac.il/zeevmaoz/dyadmid.doc
. 
. #delimit ;
delimiter now ;
. clear;

. set memory 85040k;
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. infile int ccode1 int ccode2 int year int cwongo int cwongonm int cwmid int cwmidnm int cwdynm int cwhost1 int cwhost2 int cwkeynum byte
>  cwjoany byte cwjomid int cwfatald int mzongo int mzongonm int mzmid int mzmidnm int mzhost1 int mzhost2 int mzkeynum byte mzjoany byte 
> mzjomid int mzfatald  using "dyad_year_origonly.out";
'ccode1' cannot be read as a number for ccode1[1]
'ccode2' cannot be read as a number for ccode2[1]
'year' cannot be read as a number for year[1]
'cwongo' cannot be read as a number for cwongo[1]
'cwongonm' cannot be read as a number for cwongonm[1]
'cwmid' cannot be read as a number for cwmid[1]
'cwmidnm' cannot be read as a number for cwmidnm[1]
'cwdynm' cannot be read as a number for cwdynm[1]
'cwhost1' cannot be read as a number for cwhost1[1]
'cwhost2' cannot be read as a number for cwhost2[1]
'cwkeynum' cannot be read as a number for cwkeynum[1]
'cwjoany' cannot be read as a number for cwjoany[1]
'cwjomid' cannot be read as a number for cwjomid[1]
'cwfatald' cannot be read as a number for cwfatald[1]
'mzongo' cannot be read as a number for mzongo[1]
'mzongonm' cannot be read as a number for mzongonm[1]
'mzmid' cannot be read as a number for mzmid[1]
'mzmidnm' cannot be read as a number for mzmidnm[1]
'mzhost1' cannot be read as a number for mzhost1[1]
'mzhost2' cannot be read as a number for mzhost2[1]
'mzkeynum' cannot be read as a number for mzkeynum[1]
'mzjoany' cannot be read as a number for mzjoany[1]
'mzjomid' cannot be read as a number for mzjomid[1]
'mzfatald' cannot be read as a number for mzfatald[1]
(805240 observations read)

. * The next command drops the case that was read 
> *  if the user included a line of variable names;
. drop if missing(ccode1) | missing(year);
(1 observation deleted)

. * Interpret missing values;
.  mvdecode ccode1 ccode2 year cwongo cwongonm cwmid cwmidnm cwdynm cwhost1 cwhost2 cwkeynum cwjoany cwjomid cwfatald mzongo mzongonm mzmi
> d mzmidnm mzhost1 mzhost2 mzkeynum mzjoany mzjomid mzfatald , mv(-9);
      cwongo: 129121 missing values generated
    cwongonm: 129121 missing values generated
       cwmid: 129121 missing values generated
     cwmidnm: 129121 missing values generated
      cwdynm: 129121 missing values generated
     cwhost1: 129121 missing values generated
     cwhost2: 129121 missing values generated
    cwkeynum: 129121 missing values generated
     cwjoany: 129121 missing values generated
     cwjomid: 129121 missing values generated
    cwfatald: 129735 missing values generated
      mzongo: 129121 missing values generated
    mzongonm: 129121 missing values generated
       mzmid: 129121 missing values generated
     mzmidnm: 129121 missing values generated
     mzhost1: 129121 missing values generated
     mzhost2: 129121 missing values generated
    mzkeynum: 129121 missing values generated
     mzjoany: 129121 missing values generated
     mzjomid: 129121 missing values generated
    mzfatald: 129725 missing values generated

. * Variable labels where available (see EUGeneDocumentation.doc for full information);
.  label variable ccode1 "COW CCode Num for state 1";

. label variable ccode2 "COW CCode Num for state 2";

. label variable year "Year of observation";

. label variable cwongo "A MID was ongoing at the beginning of this year, COW MID data";

. label variable cwongonm "Num of the MID that was ongoing at the beginning of the year, if any";

. label variable cwmid "MID Onset:  A MID occurred betw cc1 and cc2 in year (0=no, 1=yes).  ";

. label variable cwmidnm "Num of the new MID that began in this year, if any;  marks dispute ONSET";

. label variable cwdynm "Dyadic MID number (new number for each dyad-episode within each MID)";

. label variable cwhost1 "Relevant hostility level reached by cc1 in a MID vs. cc2 in this year";

. label variable cwhost2 "Relevant hostility level reached by cc2 in a MID vs. cc1 in this year";

. label variable cwkeynum "Key MID number: Num of MID for which other MID variables are reported.  ";

. label variable cwjoany "In this dyad, in any MID in this year, one of the states was a latecomer";

. label variable cwjomid "One of the states was a joiner in MID Num in cwkeynum in this dyad-year, cow dat";

. label variable cwfatald "Overall dispute fatality level (cow data)";

. label variable mzongo "A MID was ongoing at beginning of year, Maoz dyadic data plus MID 3.0";

. label variable mzongonm "Num of the MID that was ongoing at the beginning of the year, if any";

. label variable mzmid "MID Onset: MID occurred betw cc1 and cc2 in year (0=no, 1=yes) (maoz data).";

. label variable mzmidnm "Num of the new MID that began in this year, if any (0 if no MID was ongoing)";

. label variable mzhost1 "Relevant hostility level reached by cc1 in a MID vs. cc2 in this year ";

. label variable mzhost2 "Relevant hostility level reached by cc2 in a MID vs. cc1 in this year";

. label variable mzkeynum "Key MID number: Num of MID for which other MID variables are reported.  ";

. label variable mzjoany "In this dyad, in any MID in this year, one of the states was a latecomer";

. label variable mzjomid "One of the states was a joiner in MID Num in cwkeynum in this dyad-year, mz dat";

. label variable mzfatald "Overall dispute fatality level (maoz data)";

. compress;
cwongo was int now byte
cwmid was int now byte
cwhost1 was int now byte
cwhost2 was int now byte
cwfatald was int now byte
mzongo was int now byte
mzmid was int now byte
mzhost1 was int now byte
mzhost2 was int now byte
mzfatald was int now byte

. 
end of do-file

. tab mzongo mzmid, m

 A MID was |
ongoing at |
 beginning |
  of year, |
      Maoz | MID Onset: MID occurred betw cc1
    dyadic |  and cc2 in year (0=no, 1=yes)
 data plus |           (maoz data).
   MID 3.0 |         0          1          . |     Total
-----------+---------------------------------+----------
         0 |   672,334      2,204          0 |   674,538 
         1 |     1,387        193          0 |     1,580 
         . |         0          0    129,121 |   129,121 
-----------+---------------------------------+----------
     Total |   673,721      2,397    129,121 |   805,239 


. 
. *This confirms that Maoz's onset (mzmid) and ongoing (mzongo) MIDs do not correspond to the recommendations of Bennett and Stam, and oth
> ers. Dyad-years experiencing the onset of a MID are not coded as having a MID ongoing, similarly dyad-years that have an ongoing MID do 
> not have a missing values for onset. One must therefore create such variables from Maoz's basic variables. See also page 40 of Eugene do
> cumentation
. 
end of do-file

. *Produces correlation between ln(GDP) and Ln(LifeDeer), and examines Maoz DVs 
. 
. ***Preparing "MM_precise.dta"***
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. do "12-06-23_MM_precise_rep.do"

. **The following code is taken verbatim from "Mous_ISQ DPUNR.do" except for the modifications noted by comments with AD. 
. 
. ****Begin AD Modified Code****
. clear

. 
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. 
. clear 

. use "MM_files/EUGMar11.dta", clear

. ****End AD Modified Code****
. 
. *ongoing years included, but not as Y events
. drop if year <1947
(71395 observations deleted)

. 
. 
. merge 1:1 ccode1 ccode2 year using "MM_files/distance.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                        41,789
        from master                    41,789  (_merge==1)
        from using                          0  (_merge==2)

    matched                           511,998  (_merge==3)
    -----------------------------------------

. 
. *AD*merge 1:1 ccode1 ccode2 year using "C:\Users\mmousseau\Documents\Working Papers Data Sets\distance.dta"
. 
. drop if  _merge==2
(0 observations deleted)

. drop  _merge

. 
. replace         tpop_1          =. if tpop_1            ==-9
(16 real changes made, 16 to missing)

. replace         tpop_2          =. if tpop_2            ==-9
(123 real changes made, 123 to missing)

. replace         energy_1        =. if energy_1  ==-9
(3039 real changes made, 3039 to missing)

. replace         energy_2        =. if energy_2  ==-9
(2830 real changes made, 2830 to missing)

. replace         cap_1           =. if cap_1             ==-9
(16 real changes made, 16 to missing)

. replace         cap_2           =. if cap_2             ==-9
(123 real changes made, 123 to missing)

. replace         mzfatald        =. if mzfatald  ==-9
(375 real changes made, 375 to missing)

. replace         polity21        =. if polity21  ==-99
(69897 real changes made, 69897 to missing)

. replace         polity22        =. if polity22  ==-99
(47535 real changes made, 47535 to missing)

. 
. g cpl = cap_1 if cap_1 < cap_2 & cap_1~=. & cap_2~=.
(262260 missing values generated)

. replace cpl = cap_2 if cap_2 <= cap_1 & cap_1~=. & cap_2~=.
(262121 real changes made)

. g cph = cap_1 if cap_1 > cap_2 & cap_1~=. & cap_2~=.
(292087 missing values generated)

. replace cph = cap_2 if cap_2 >= cap_1 & cap_1~=. & cap_2~=.
(291948 real changes made)

. g lncprt=ln(cph/cpl) if cph~=. & cpl~=.
(1086 missing values generated)

. drop cap_1 cap_2 cpl cph

. label variable lncprt "Relative capability"

. g mjpw=0

. replace mjpw=1 if majpow1==1 | majpow2==1
(40664 real changes made)

. drop majpow1 majpow2

. label variable mjpw "Major power"

. 
. 
. g cntg=0 

. replace cntg = 1 if contig <= 5
(20360 real changes made)

. drop contig

. label variable cntg "Contiguity"

. 
. 
. g dist=ln(distance) if distance~=.
(41789 missing values generated)

. drop distance

. label variable dist "Distance"

. 
. 
. g edv1= energy_1/ tpop_1
(3039 missing values generated)

. g edv2= energy_2/ tpop_2
(2830 missing values generated)

. g edvl= ln(edv1+1) if edv1 ~=. & edv2 ~=.
(5861 missing values generated)

. replace edvl= ln(edv2+1) if edv2<edv1 & edv1 ~=. & edv2 ~=.
(309971 real changes made)

. drop energy_1 energy_2 

. label variable edvl "WealthL"

. 
. sort ccode1 ccode2 year

. 
. g mzfmid=0 if mzmid~=. & mzfatald~=.
(375 missing values generated)

. replace  mzfmid=1 if  mzfatald>=1 & mzmid==1 & mzfatald~=. & mzmid~=.
(316 real changes made)

. 
. gen double ID= (1000000*ccode1)+ccode2

. g mzfmidl = mzfmid[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(19695 missing values generated)

. 
. **AD modified
. label variable mzfmidl "MM Fatal MID Onset Lead" 

. **END AD modified
. 
. g mzmidl = mzmid[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(19330 missing values generated)

. **AD modified
. label variable mzmidl "MM MID Onset Lead" 

. **End AD modified
. 
. 
. sort ID

. btscs mzfmidl year ID, g(fpceyrs) nspline(3)

. rename  _spline1  fspl1

. rename  _spline2  fspl2

. rename  _spline3  fspl3

. btscs mzmidl year ID, g(apceyrs) nspline(3)

. rename  _spline1  aspl1

. rename  _spline2  aspl2

. rename  _spline3  aspl3

. 
. rename mzmidl mzamidl

. 
. ****Begin AD Modified Code****
. label variable mzamidl "MM MID Onset Lead"

. 
. *Variable labels from EUGene
. label variable mzongo "A MID was ongoing at beginning of year, Maoz dyadic data plus MID 3.0"

. label variable mzongonm "Num of the MID that was ongoing at the beginning of the year, if any"

. label variable mzmid "MID Onset: MID occurred betw cc1 and cc2 in year (0=no, 1=yes) (maoz data)."

. label variable mzmidnm "Num of the new MID that began in this year, if any (0 if no MID was ongoing)"

. 
. 
. 
. *Constructing Fatal MID Ongoing and MID Ongoing in same erroneous way. 
. g mzfmidong=0 if mzongo~=. & mzfatald~=.
(375 missing values generated)

. replace  mzfmidong=1 if  mzfatald>=1 & mzongo==1 & mzfatald~=. & mzongo~=.
(466 real changes made)

. g mzfmidongl = mzfmidong[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(19695 missing values generated)

. label variable mzfmidongl "MM Fatal MID Ongoing Lead"

. 
. sort ccode1 ccode2 year

. g mzongol = mzongo[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(19330 missing values generated)

. label variable mzongol "MM MID Ongoing Lead"

. 
. g dyadid=ccode1*10000+ccode2

. 
. g mzmido=1 if mzmid==1 | mzongo==1
(551571 missing values generated)

. replace mzmido=0 if mzmid==0 & mzongo==0
(551571 real changes made)

. label variable mzmido "MID Ongoing"

. 
. *mzfmido means maoz fatal mid ongoing
. g mzfmido=0 if mzfatald~=.
(375 missing values generated)

. replace  mzfmido=1 if  mzfatald>=1  & mzfatald~=.
(927 real changes made)

. label variable mzfmido "Fatal MID Ongoing"

. 
. *Fatal MID Onset defined as a Fatal MID Ongoing, and last year there was not a Fatal MID with the same MID number. If there was, then Fa
> tal MID Onset =.
. g mzfmidon=mzfmido
(375 missing values generated)

. sort dyadid year

. by dyadid: replace mzfmidon=. if  mzfmido==1 & mzfmido[_n-1]==1 & dyadid==dyadid[_n-1] & mzkeynum==mzkeynum[_n-1]
(413 real changes made, 413 to missing)

. label variable mzfmidon "Fatal MID Onset"

. tab mzfmido mzfmidon, m 

 Fatal MID |         Fatal MID Onset
   Ongoing |         0          1          . |     Total
-----------+---------------------------------+----------
         0 |   552,485          0          0 |   552,485 
         1 |         0        514        413 |       927 
         . |         0          0        375 |       375 
-----------+---------------------------------+----------
     Total |   552,485        514        788 |   553,787 


. 
. g mzwaro=0 

. replace mzwaro=1 if  mzfatald==6  
(399 real changes made)

. 
. label variable mzwaro "War Ongoing"

. 
. sort ID year

. g mzfmidol = mzfmido[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(19695 missing values generated)

. g mzfmidonl = mzfmidon[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(20108 missing values generated)

. g mzmidol=mzmido[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(19330 missing values generated)

. g mzwarol=mzwaro[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(19330 missing values generated)

. 
. label variable mzmidol "MID Ongoing Lead"

. label variable mzfmidonl "Fatal MID Onset Lead"

. label variable mzfmidol "Fatal MID Ongoing Lead"

. label variable mzwarol "War Ongoing Lead"

. 
. *mzmidonl is corrected mid onset lead
. g mzmidonl=mzmid[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1
(19330 missing values generated)

. replace mzmidonl=. if mzmidonl==0 & mzongo[_n+1]==1
(729 real changes made, 729 to missing)

. label variable mzmidonl "MID Onset Lead"

. 
. ***Merging Original Beck and Webb data
. rename year year1

. sort ccode1 year1

. 
. merge m:1 ccode1 year1 using "beck_webb1.dta"
year1 was int now float

    Result                           # of obs.
    -----------------------------------------
    not matched                       337,751
        from master                   337,510  (_merge==1)
        from using                        241  (_merge==2)

    matched                           216,277  (_merge==3)
    -----------------------------------------

. keep if _merge==3 | _merge==1
(241 observations deleted)

. drop _merge

. 
. 
. rename year1 year2

. sort ccode2 year2

. 
. merge m:1 ccode2 year2 using "beck_webb2.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                       377,801
        from master                   377,535  (_merge==1)
        from using                        266  (_merge==2)

    matched                           176,252  (_merge==3)
    -----------------------------------------

. keep if _merge==3 | _merge==1
(266 observations deleted)

. drop _merge

. 
. rename year2 year

. gen CIEnl=log(min(lifedeer1, lifedeer2)+1)  if lifedeer1~=. & lifedeer2~=.
(514782 missing values generated)

. 
. 
. ****End AD Modified Code****
. 
. 
. 
. drop mzfmid upop_2 irst_2  milex_2 milper_2 upop_1 irst_1  milex_1 milper_1 mzongo mzongonm mzmid mzmidnm mzhost1 mzhost2 mzkeynum mzfat
> ald mzpceyrs

. 
. *AD*g dyadid=ccode1*10000+ccode2
. 
. *AD*drop if year <1960
. 
. ****Begin AD Modified Code****
. ***Avoid dropping all years***
. gen MMsample=1 if year>=1960
(41626 missing values generated)

. *drop if year <1960
. 
. save "MM_precise.dta", replace
file MM_precise.dta saved

. 
. use "MM_precise.dta", clear

. ****End AD Modified Code****
. 
. 
. *AD*save "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", replace
. *AD*use "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", clear
. 
. 
. *AD*
. *AD*merge 1:1 year dyadid using "C:\Users\mmousseau\Documents\Working Papers Data Sets\Gleditsch Trade.dta"
. *AD*drop if  _merge==2
. *AD*drop  _merge
. *AD*
. 
. *AD*merge 1:1 dyadid year using "C:\Users\mmousseau\Documents\Working Papers Data Sets\Gartzke.dta"
. *AD*drop  _merge
. *AD*
. *AD*sort ccode2 year
. *AD*merge m:1 ccode2 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\PWT_Gleditsch2.dta"
. *AD*drop if  _merge==2
. *AD*drop  _merge
. *AD*
. 
. *AD*merge m:1 ccode2 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\McDon_2.dta"
. *AD*drop if  _merge==2
. *AD*drop  _merge
. *AD*
. 
. *AD*sort ccode1 year
. *AD*merge m:1 ccode1 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\PWT_Gleditsch1.dta"
. *AD*drop if  _merge==2
. *AD*drop  _merge
. *AD*merge m:1 ccode1 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\McDon_1.dta"
. *AD*drop if  _merge==2
. *AD*drop  _merge
. *AD*
. 
. *AD*sort  ccode2 year
. *AD*merge m:1 ccode2 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\CINE 2011.2.15 ccode2.dta"
. *AD*drop if  _merge==2
. *AD*drop  _merge
. *AD*sort  ccode1 year
. *AD*merge m:1 ccode1 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\CINE 2011.2.15 ccode1.dta"
. *AD*drop if  _merge==2
. *AD*drop  _merge
. *AD*
. 
. *AD*
. 
. *AD*merge 1:1 ccode1 ccode2 year using "C:\Users\mmousseau\Documents\Working Papers Data Sets\Political Dissimilarity Werner.dta"
. *AD*drop if  _merge==2
. *AD*drop  _merge
. 
. 
. 
. ****Begin AD Modified Code****
. 
. merge 1:1 year dyadid using "MM_files/Gleditsch Trade.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                        90,692
        from master                    32,625  (_merge==1)
        from using                     58,067  (_merge==2)

    matched                           521,162  (_merge==3)
    -----------------------------------------

. 
. drop if  _merge==2
(58067 observations deleted)

. 
. drop  _merge

. 
. 
. 
. merge 1:1 dyadid year using "MM_files/Gartzke.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                       190,900
        from master                   187,249  (_merge==1)
        from using                      3,651  (_merge==2)

    matched                           366,538  (_merge==3)
    -----------------------------------------

. 
. drop  _merge

. 
. 
. 
. sort ccode2 year

. 
. merge m:1 ccode2 year using "MM_files/PWT_Gleditsch2.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                        32,625
        from master                    32,569  (_merge==1)
        from using                         56  (_merge==2)

    matched                           524,869  (_merge==3)
    -----------------------------------------

. 
. drop if  _merge==2
(56 observations deleted)

. 
. drop  _merge

. 
. 
. 
. merge m:1 ccode2 year using "MM_files/McDon_2.dta"
ccode2 was int now float

    Result                           # of obs.
    -----------------------------------------
    not matched                         6,194
        from master                     5,949  (_merge==1)
        from using                        245  (_merge==2)

    matched                           551,489  (_merge==3)
    -----------------------------------------

. 
. drop if  _merge==2
(245 observations deleted)

. 
. drop  _merge

. 
. 
. 
. sort ccode1 year

. 
. merge m:1 ccode1 year using "MM_files/PWT_Gleditsch1.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                        28,703
        from master                    28,672  (_merge==1)
        from using                         31  (_merge==2)

    matched                           528,766  (_merge==3)
    -----------------------------------------

. 
. drop if  _merge==2
(31 observations deleted)

. 
. drop  _merge

. 
. merge m:1 ccode1 year using "MM_files/McDon_1.dta"
ccode1 was int now float

    Result                           # of obs.
    -----------------------------------------
    not matched                         7,917
        from master                     7,672  (_merge==1)
        from using                        245  (_merge==2)

    matched                           549,766  (_merge==3)
    -----------------------------------------

. 
. drop if  _merge==2
(245 observations deleted)

. 
. drop  _merge

. 
. 
. 
. sort  ccode2 year

. 
. merge m:1 ccode2 year using "MM_files/CINE 2011.2.15 ccode2.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                       107,163
        from master                   107,122  (_merge==1)
        from using                         41  (_merge==2)

    matched                           450,316  (_merge==3)
    -----------------------------------------

. 
. **AD**
. *This data file was apparently constructed using a version of "CINE Data Replication Do File.do" and "raw for replication.dta"
. *****
. 
. drop if  _merge==2
(41 observations deleted)

. 
. drop  _merge

. 
. sort  ccode1 year

. 
. merge m:1 ccode1 year using "MM_files/CINE 2011.2.15 ccode1.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                        91,278
        from master                    91,237  (_merge==1)
        from using                         41  (_merge==2)

    matched                           466,201  (_merge==3)
    -----------------------------------------

. 
. drop if  _merge==2
(41 observations deleted)

. 
. drop  _merge

. 
. 
. 
. 
. 
. merge 1:1 ccode1 ccode2 year using "MM_files/Political Dissimilarity Werner.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                        45,277
        from master                    45,277  (_merge==1)
        from using                          0  (_merge==2)

    matched                           512,161  (_merge==3)
    -----------------------------------------

. 
. drop if  _merge==2
(0 observations deleted)

. 
. drop  _merge

. 
. 
. save "MM_precise.dta", replace
file MM_precise.dta saved

. 
. use "MM_precise.dta", clear

. ****End AD Modified Code****
. 
. *AD*
. *AD*save "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", replace
. *AD*use "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", clear
. *AD*
. 
. 
. replace         capopenl        =. if capopenl  ==-9
(189420 real changes made, 189420 to missing)

. replace         pub1    =. if pub1              ==-9
(0 real changes made)

. replace         pub2    =. if pub2              ==-9
(0 real changes made)

. 
. g CIEl= CIE1 if CIE1~=. & CIE2~=.
(228882 missing values generated)

. replace CIEl= CIE2 if CIE1> CIE2 & CIE1~=. & CIE2~=.
(197636 real changes made)

. label variable CIEl "CIEL"

. 
. g bCIE=0 if CIEd1~=. | CIEd2~=.
(76757 missing values generated)

. replace bCIE=1 if CIEd1==1 & CIEd2==1
(8897 real changes made)

. label variable bCIE "CIEBinary"

. 
. g dml=polity21 if polity21~=. & polity22~=.
(113776 missing values generated)

. replace dml= polity22 if polity21> polity22 & polity21~=. & polity22~=.
(238836 real changes made)

. g dmh=polity21 if polity21~=. & polity22~=.
(113776 missing values generated)

. replace dmh= polity22 if polity21< polity22 & polity21~=. & polity22~=.
(156281 real changes made)

. g dmdist = dmh-dml if dmh~=. & dml~=.
(113776 missing values generated)

. *drop polity21 polity22 
. label variable dml "DemocracyL"

. 
. label variable dmdist "Regime Difference"

. 
. 
. 
. ****Begin AD Modified Code****
. *recentering dml 75th percentile
. sum dml, d

                         DemocracyL
-------------------------------------------------------------
      Percentiles      Smallest
 1%          -10            -10
 5%          -10            -10
10%           -9            -10       Obs              443662
25%           -8            -10       Sum of Wgt.      443662

50%           -7                      Mean          -4.239072
                        Largest       Std. Dev.      5.868515
75%           -2             10
90%            7             10       Variance       34.43947
95%            9             10       Skewness       1.224489
99%           10             10       Kurtosis       3.117444

. gen dmlc=dml-r(p75)
(113776 missing values generated)

. 
. sum CIEl, d

                            CIEL
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%            0              0
10%            0              0       Obs              328556
25%     .2730841              0       Sum of Wgt.      328556

50%     .8533113                      Mean           1.090047
                        Largest       Std. Dev.      1.137458
75%     1.530647       7.891397
90%     2.377811       7.954988       Variance        1.29381
95%     3.213251        7.97104       Skewness       2.000386
99%     5.801502       8.012553       Kurtosis       8.519958

. gen CIElc=CIEl-r(p75)
(228882 missing values generated)

. 
. sum CIEl, d

                            CIEL
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%            0              0
10%            0              0       Obs              328556
25%     .2730841              0       Sum of Wgt.      328556

50%     .8533113                      Mean           1.090047
                        Largest       Std. Dev.      1.137458
75%     1.530647       7.891397
90%     2.377811       7.954988       Variance        1.29381
95%     3.213251        7.97104       Skewness       2.000386
99%     5.801502       8.012553       Kurtosis       8.519958

. gen CIElc2=CIEl-r(p90)
(228882 missing values generated)

. 
. gen dmlCIElc=dml*CIElc
(235627 missing values generated)

. gen dmlCIElc2=dml*CIElc2
(235627 missing values generated)

. ****End AD Modified Code****
. 
. 
. g bdm=0 if dml~=.
(113776 missing values generated)

. replace bdm=1 if dml >=7 & dml~=.
(45970 real changes made)

. label variable bdm "DemocracyBinary6"

. 
. 
. g h10dm=0 if  dml~=.
(113776 missing values generated)

. replace h10dm=1 if  dml==10 & dml~=.
(13886 real changes made)

. replace h10dm=. if  dml==.
(0 real changes made)

. label variable h10dm "DemocracyBinary10"

. 
. 
. gen dml2=dml+10
(113776 missing values generated)

. 
. gen dmlsq=dml2^2
(113776 missing values generated)

. 
. label variable dmlsq "DemocracyL^2"

. 
. g dvl= ln(rgdp96pc1) if rgdp96pc1 ~=. & rgdp96pc2 ~=.
(35468 missing values generated)

. replace dvl= ln(rgdp96pc2) if rgdp96pc2<rgdp96pc1 & rgdp96pc1 ~=. & rgdp96pc2 ~=.
(314652 real changes made)

. drop rgdp96pc1 rgdp96pc2

. 
. g dpl=dp1*100 if dp1~=. & dp2~=.
(41607 missing values generated)

. replace dpl= dp2*100 if dp1> dp2 & dp1~=. & dp2~=.
(140339 real changes made)

. drop dp1 dp2

. label variable dpl "TradeL"

. 
. g pubh=pub1 if pub1~=. & pub2~=.
(398016 missing values generated)

. replace pubh= pub2 if pub2> pub1 & pub1~=. & pub2~=.
(95391 real changes made)

. drop pub1 pub2

. label variable pubh "PublicH"

. 
. 
. sort dyadid

. gen capopenl2=capopenl
(376669 missing values generated)

. replace capopenl2=0 if (capopenl==. & year>=1966 & year<1993)
(135376 real changes made)

. labe variable capopenl  "CAPOPENL (Gartzke 2007)"

. labe variable capopenl2 "CAPOPENL (Gartzke & Hewitt 2010)"

. by dyadid: ipolate capopenl year, gen(capopenl_ipol)
(374220 missing values generated)

. gen capopenl_ipol2=capopenl_ipol
(374220 missing values generated)

. replace capopenl_ipol2=0 if (capopenl_ipol==. & year>=1966 & year<=1992)
(132927 real changes made)

. labe variable capopenl_ipol2 "Capital OpennessL"

. 
. g misscpl=0

. replace misscpl=1 if capopenl==. 
(376669 real changes made)

. replace misscpl = . if year <1966
(82888 real changes made, 82888 to missing)

. replace misscpl = . if year > 1992
(158405 real changes made, 158405 to missing)

. tab misscpl mzfmidl

           |  MM Fatal MID Onset
           |         Lead
   misscpl |         0          1 |     Total
-----------+----------------------+----------
         0 |   180,592         80 |   180,672 
         1 |   131,110         69 |   131,179 
-----------+----------------------+----------
     Total |   311,702        149 |   311,851 


. 
. g incrrctmiss=0

. replace incrrctmiss =1 if capopenl ==. & capopenl_ipol~=.
(2449 real changes made)

. replace incrrctmiss = . if year <1966
(82888 real changes made, 82888 to missing)

. replace incrrctmiss = . if year > 1992
(158405 real changes made, 158405 to missing)

. tab incrrctmiss mzfmidl

           |  MM Fatal MID Onset
incrrctmis |         Lead
         s |         0          1 |     Total
-----------+----------------------+----------
         0 |   309,302        126 |   309,428 
         1 |     2,400         23 |     2,423 
-----------+----------------------+----------
     Total |   311,702        149 |   311,851 


. 
. 
. sum year if year >1960

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        year |    510141    1984.293    11.41348       1961       2001

. 
. 
. 
. ****Begin AD Modified Code****
. replace MMsample=. if CIEl==.
(183605 real changes made, 183605 to missing)

. *drop if CIEl==.
. ****End AD Modified Code****
. 
. *AD*drop if CIEl==.
. 
. 
. ****Begin AD Modified Code****
. **"12-06-13_mids.dta" is a file that we constructed from scratch, in a manner similar to how Mousseau constructed his data file. 
. *From: "AD_data_merge.do"
. sort ccode1 ccode2 year

. merge 1:1 ccode1 ccode2 year using "12-06-13_mids.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                       255,103
        from master                     3,651  (_merge==1)
        from using                    251,452  (_merge==2)

    matched                           553,787  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(251452 observations deleted)

. drop if _merge==1
(3651 observations deleted)

. drop _merge

. 
. drop midyears* fmidyears* waryears* 

. 
. sort ID

. btscs mzmidol year ID, g(midyears) nspline(3)

. rename  _spline1  midyears2

. rename  _spline2  midyears3

. rename  _spline3  midyears4

. 
. 
. btscs mzfmidol year ID, g(fatalyears) nspline(3)

. rename  _spline1  fatalyears2

. rename  _spline2  fatalyears3

. rename  _spline3  fatalyears4

. 
. save "MM_precise.dta", replace
file MM_precise.dta saved

. ****End AD Modified Code****
. 
. *AD*save "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", replace
. 
. 
. 
. 
. 
end of do-file

. 
. 
. ***Preparing "midata.dta"***
. clear

. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. do "12-06-24_prep_mul-imputation.do"

. *Preparing Imputation files
. *12-06-24_prep_mul-imputation.do
. 
. clear

. 
. *global filetree /Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/Mousseau_Replication_Files/
. 
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. 
. set more off

. 
. **Importing dyad-year dataset from EUGene
. do "12-05-28_dyad.out.do"

. * STATA command file generated by EUGene  3.20 to read data file
. * "\\psf\Home\Documents\EUGene_Output\12-05-28_dyad.out"
. * To execute this command file: 
. *    1) Run STATA,
. *    2) "cd" to directory "\\psf\Home\Documents\EUGene_Output\",
. *    3) enter command "do 12-05-28_dyad.out.do".
. 
. * Number of observations in this data set: 805239
. 
. * Data set specifications:
. *   Base Format: Non-directed Dyad
. *   Time Span: 1816 to 2008
. *   Selected Subset: All dyads included)
. *   Sampling: None (100% of available data written to file)
. *   Variables included:
. *        ccode1 ccode2  year    abbrev1 abbrev2 cap_1   cap_2   milper_1        milex_1 energy_1        irst_1  upop_1  tpop_1  milper_2
>         milex_2 energy_2        irst_2  upop_2  tpop_2  majpow1 majpow2 rlreg12 rlreg21 contig  distance        numstate        numGPs  
> cwongo  cwongonm        cwmid   cwmidnm cwdynm  cwhost1 cwhost2 cwhostd cwkeynum        cworig1 cworig2 cwmidnme        cwstmo1 cwstday1
>         cwstyr1 cwstmo2 cwstday2        cwstyr2 cwendmo1        cwenddy1        cwendyr1        cwendmo2        cwenddy2        cwendyr2
>         cwrevt11        cwrevt21        cwrevt12        cwrevt22        cwfatal1        cwfatex1        cwfatal2        cwfatex2        
> cwhiact1        cwhiact2        cwhiactd        cwoutcm cwsettle        cwfatald        cwrecip cwnumst1        cwnumst2        cwpceyrs
>         democ1  democ2  autoc1  autoc2  polity1 polity2 polity21        polity22
. *   Selected settings for variables with multiple output options:
. *        Distance variable measured using capitol coordinates and land contiguity, including modifications from The War Trap
. *        Peace years calculated using Werner peace year adjustment
. *       Dispute characteristics:
. *        When two or more disputes occur in a year, data is from the highest intensity dispute
. *        Disputes marked for originators only
. *        All dyad-years with an ongoing MID dropped
. *        Ongoing dispute years not considered new initiations
. *        Joiner Dyads included
. 
. * Note:  EUGene draws on datasets originally published elsewhere by other scholars.  When 
. * presenting analysis using data generated by EUGene, please cite the original data sources 
. * as well as EUGene (see EUGene documentation, Appendix D) 
. *
. * Bibliography for this data set:
. * Beck, Nathaniel, Jonathan Katz, and Richard Tucker.  1997.  "Taking Time Seriously:  Time-Series - Cross-Section Analysis with a Binar
> y Dependent Variable."  American Journal of Political Science 42 (October); 1260-1288.
. * Bueno de Mesquita, Bruce.  1981.  The War Trap.  New Haven: Yale University Press.
. * Jones, Daniel M., Stuart A. Bremer and J. David Singer 1996.  "Militarized Interstate Disputes, 1816-1992: Rationale, Coding Rules, an
> d Empirical Patterns."          Conflict Management and Peace Science 15(2); 163:213.
. * Small, Melvin, and J. David Singer.  1969.  "Formal Alliances, 1815-1965:  An Extension of the Basic Data."  Journal of Peace Research
>  6: 257-282.  
. * Werner, Suzanne.  2000.  "The Effects of Political Similarity on the Onset of Militarized Disputes, 1816-1985."  Political Research Qu
> arterly 53(2): 343-374.
. * 
. * 
. * Marshall, Monty G. and Keith Jaggers. 2002. Polity IV Project: Political Regime Characteristics and Transitions, 1800-2002. http://www
> .cidcm.umd.edu/inscr/polity/index.htm.
. 
. #delimit ;
delimiter now ;
. clear;

. set memory 268421k;
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. infile int ccode1 int ccode2 int year str3 abbrev1 str3 abbrev2 float cap_1 float cap_2 float milper_1 float milex_1 float energy_1 floa
> t irst_1 float upop_1 float tpop_1 float milper_2 float milex_2 float energy_2 float irst_2 float upop_2 float tpop_2 byte majpow1 byte 
> majpow2 byte rlreg12 byte rlreg21 byte contig float distance int numstate int numGPs int cwongo int cwongonm int cwmid int cwmidnm int c
> wdynm int cwhost1 int cwhost2 byte cwhostd int cwkeynum byte cworig1 byte cworig2 str40 cwmidnme int cwstmo1 int cwstday1 int cwstyr1 in
> t cwstmo2 int cwstday2 int cwstyr2 int cwendmo1 int cwenddy1 int cwendyr1 int cwendmo2 int cwenddy2 int cwendyr2 byte cwrevt11 byte cwre
> vt21 byte cwrevt12 byte cwrevt22 int cwfatal1 int cwfatex1 int cwfatal2 int cwfatex2 byte cwhiact1 byte cwhiact2 byte cwhiactd byte cwou
> tcm byte cwsettle int cwfatald byte cwrecip int cwnumst1 int cwnumst2 int cwpceyrs long democ1 long democ2 long autoc1 long autoc2 long 
> polity1 long polity2 long polity21 long polity22  using "12-05-28_dyad.out";
'ccode1' cannot be read as a number for ccode1[1]
'ccode2' cannot be read as a number for ccode2[1]
'year' cannot be read as a number for year[1]
'cap_1' cannot be read as a number for cap_1[1]
'cap_2' cannot be read as a number for cap_2[1]
'milper_1' cannot be read as a number for milper_1[1]
'milex_1' cannot be read as a number for milex_1[1]
'energy_1' cannot be read as a number for energy_1[1]
'irst_1' cannot be read as a number for irst_1[1]
'upop_1' cannot be read as a number for upop_1[1]
'tpop_1' cannot be read as a number for tpop_1[1]
'milper_2' cannot be read as a number for milper_2[1]
'milex_2' cannot be read as a number for milex_2[1]
'energy_2' cannot be read as a number for energy_2[1]
'irst_2' cannot be read as a number for irst_2[1]
'upop_2' cannot be read as a number for upop_2[1]
'tpop_2' cannot be read as a number for tpop_2[1]
'majpow1' cannot be read as a number for majpow1[1]
'majpow2' cannot be read as a number for majpow2[1]
'rlreg12' cannot be read as a number for rlreg12[1]
'rlreg21' cannot be read as a number for rlreg21[1]
'contig' cannot be read as a number for contig[1]
'distance' cannot be read as a number for distance[1]
'numstate' cannot be read as a number for numstate[1]
'numGPs' cannot be read as a number for numGPs[1]
'cwongo' cannot be read as a number for cwongo[1]
'cwongonm' cannot be read as a number for cwongonm[1]
'cwmid' cannot be read as a number for cwmid[1]
'cwmidnm' cannot be read as a number for cwmidnm[1]
'cwdynm' cannot be read as a number for cwdynm[1]
'cwhost1' cannot be read as a number for cwhost1[1]
'cwhost2' cannot be read as a number for cwhost2[1]
'cwhostd' cannot be read as a number for cwhostd[1]
'cwkeynum' cannot be read as a number for cwkeynum[1]
'cworig1' cannot be read as a number for cworig1[1]
'cworig2' cannot be read as a number for cworig2[1]
'cwstmo1' cannot be read as a number for cwstmo1[1]
'cwstday1' cannot be read as a number for cwstday1[1]
'cwstyr1' cannot be read as a number for cwstyr1[1]
'cwstmo2' cannot be read as a number for cwstmo2[1]
'cwstday2' cannot be read as a number for cwstday2[1]
'cwstyr2' cannot be read as a number for cwstyr2[1]
'cwendmo1' cannot be read as a number for cwendmo1[1]
'cwenddy1' cannot be read as a number for cwenddy1[1]
'cwendyr1' cannot be read as a number for cwendyr1[1]
'cwendmo2' cannot be read as a number for cwendmo2[1]
'cwenddy2' cannot be read as a number for cwenddy2[1]
'cwendyr2' cannot be read as a number for cwendyr2[1]
'cwrevt11' cannot be read as a number for cwrevt11[1]
'cwrevt21' cannot be read as a number for cwrevt21[1]
'cwrevt12' cannot be read as a number for cwrevt12[1]
'cwrevt22' cannot be read as a number for cwrevt22[1]
'cwfatal1' cannot be read as a number for cwfatal1[1]
'cwfatex1' cannot be read as a number for cwfatex1[1]
'cwfatal2' cannot be read as a number for cwfatal2[1]
'cwfatex2' cannot be read as a number for cwfatex2[1]
'cwhiact1' cannot be read as a number for cwhiact1[1]
'cwhiact2' cannot be read as a number for cwhiact2[1]
'cwhiactd' cannot be read as a number for cwhiactd[1]
'cwoutcm' cannot be read as a number for cwoutcm[1]
'cwsettle' cannot be read as a number for cwsettle[1]
'cwfatald' cannot be read as a number for cwfatald[1]
'cwrecip' cannot be read as a number for cwrecip[1]
'cwnumst1' cannot be read as a number for cwnumst1[1]
'cwnumst2' cannot be read as a number for cwnumst2[1]
'cwpceyrs' cannot be read as a number for cwpceyrs[1]
'democ1' cannot be read as a number for democ1[1]
'democ2' cannot be read as a number for democ2[1]
'autoc1' cannot be read as a number for autoc1[1]
'autoc2' cannot be read as a number for autoc2[1]
'polity1' cannot be read as a number for polity1[1]
'polity2' cannot be read as a number for polity2[1]
'polity21' cannot be read as a number for polity21[1]
'polity22' cannot be read as a number for polity22[1]
(805240 observations read)

. * The next command drops the case that was read 
> *  if the user included a line of variable names;
. drop if missing(ccode1) | missing(year);
(1 observation deleted)

. * Interpret missing values;
.  mvdecode ccode1 ccode2 year abbrev1 abbrev2 cap_1 cap_2 milper_1 milex_1 energy_1 irst_1 upop_1 tpop_1 milper_2 milex_2 energy_2 irst_2
>  upop_2 tpop_2 majpow1 majpow2 rlreg12 rlreg21 contig distance numstate numGPs cwongo cwongonm cwmid cwmidnm cwdynm cwhost1 cwhost2 cwho
> std cwkeynum cworig1 cworig2 cwmidnme cwstmo1 cwstday1 cwstyr1 cwstmo2 cwstday2 cwstyr2 cwendmo1 cwenddy1 cwendyr1 cwendmo2 cwenddy2 cwe
> ndyr2 cwrevt11 cwrevt21 cwrevt12 cwrevt22 cwfatal1 cwfatex1 cwfatal2 cwfatex2 cwhiact1 cwhiact2 cwhiactd cwoutcm cwsettle cwfatald cwrec
> ip cwnumst1 cwnumst2 cwpceyrs , mv(-9);
     abbrev1: string variable ignored
     abbrev2: string variable ignored
       cap_1: 18721 missing values generated
       cap_2: 18721 missing values generated
    milper_1: 34181 missing values generated
     milex_1: 80169 missing values generated
    energy_1: 23952 missing values generated
      irst_1: 26390 missing values generated
      upop_1: 19150 missing values generated
      tpop_1: 19595 missing values generated
    milper_2: 37464 missing values generated
     milex_2: 90356 missing values generated
    energy_2: 28369 missing values generated
      irst_2: 23877 missing values generated
      upop_2: 21508 missing values generated
      tpop_2: 19143 missing values generated
      contig: 110785 missing values generated
      cwongo: 129121 missing values generated
    cwongonm: 129121 missing values generated
       cwmid: 129121 missing values generated
     cwmidnm: 129121 missing values generated
      cwdynm: 129121 missing values generated
     cwhost1: 129121 missing values generated
     cwhost2: 129121 missing values generated
     cwhostd: 129121 missing values generated
    cwkeynum: 129121 missing values generated
     cworig1: 129121 missing values generated
     cworig2: 129121 missing values generated
    cwmidnme: string variable ignored
     cwstmo1: 129121 missing values generated
    cwstday1: 129602 missing values generated
     cwstyr1: 129121 missing values generated
     cwstmo2: 129121 missing values generated
    cwstday2: 129602 missing values generated
     cwstyr2: 129121 missing values generated
    cwendmo1: 129121 missing values generated
    cwenddy1: 129613 missing values generated
    cwendyr1: 129121 missing values generated
    cwendmo2: 129121 missing values generated
    cwenddy2: 129613 missing values generated
    cwendyr2: 129121 missing values generated
    cwrevt11: 129121 missing values generated
    cwrevt21: 133196 missing values generated
    cwrevt12: 129121 missing values generated
    cwrevt22: 133196 missing values generated
    cwfatal1: 129748 missing values generated
    cwfatex1: 131251 missing values generated
    cwfatal2: 129733 missing values generated
    cwfatex2: 131334 missing values generated
    cwhiact1: 129121 missing values generated
    cwhiact2: 129121 missing values generated
    cwhiactd: 129121 missing values generated
     cwoutcm: 129121 missing values generated
    cwsettle: 129121 missing values generated
    cwfatald: 129735 missing values generated
     cwrecip: 129121 missing values generated
    cwnumst1: 129121 missing values generated
    cwnumst2: 129121 missing values generated
    cwpceyrs: 129121 missing values generated

. mvdecode democ1, mv(-99);
      democ1: 155492 missing values generated

. mvdecode democ2, mv(-99);
      democ2: 133345 missing values generated

. mvdecode autoc1, mv(-99);
      autoc1: 155492 missing values generated

. mvdecode autoc2, mv(-99);
      autoc2: 133345 missing values generated

. mvdecode polity1, mv(-99);
     polity1: 155492 missing values generated

. mvdecode polity2, mv(-99);
     polity2: 133345 missing values generated

. mvdecode polity21, mv(-99);
    polity21: 160589 missing values generated

. mvdecode polity22, mv(-99);
    polity22: 141225 missing values generated

. * Variable labels where available (see EUGeneDocumentation.doc for full information);
.  label variable ccode1 "COW CCode Num for state 1";

. label variable ccode2 "COW CCode Num for state 2";

. label variable year "Year of observation";

. label variable abbrev1 "Country Abbreviation state 1";

. label variable abbrev2 "Country Abbreviation state 2";

. label variable cap_1 "National Capabilities Index (CINC) for cc1";

. label variable cap_2 "National Capabilities Index (CINC) for cc2";

. label variable milper_1 "COW military personnel for cc1";

. label variable milex_1 "COW military expenditure for cc1";

. label variable energy_1 "COW energy production for cc1";

. label variable irst_1 "COW iron/steel production for cc1";

. label variable upop_1 "COW nominal urban population for cc1";

. label variable tpop_1 "COW nominal total population for cc1";

. label variable milper_2 "COW military personnel for cc2";

. label variable milex_2 "COW military expenditure for cc2";

. label variable energy_2 "COW energy production for cc2";

. label variable irst_2 "COW iron/steel production for cc2";

. label variable upop_2 "COW nominal urban population for cc2";

. label variable tpop_2 "COW nominal total population for cc2";

. label variable majpow1 "Major power status of cc1";

. label variable majpow2 "Major power status of cc2";

. label variable rlreg12 "Region relevant to Directed Dyad cc1 vs. cc2";

. label variable rlreg21 "Region relevant to Directed Dyad cc2 vs. cc1";

. label variable contig "Direct contig (1=Lnd, 2=1-12 miles watr, 3=13-24, 4=25-150, 5=151-400, 6=not)";

. label variable distance "Distance, from cc1 to cc2, in miles";

. label variable numstate "Number of states in intl system as defined by COW system membership";

. label variable numGPs "Num of great powers in the international system";

. label variable cwongo "A MID was ongoing at the beginning of this year, COW MID data";

. label variable cwongonm "Num of the MID that was ongoing at the beginning of the year, if any";

. label variable cwmid "MID Onset:  A MID occurred betw cc1 and cc2 in year (0=no, 1=yes).  ";

. label variable cwmidnm "Num of the new MID that began in this year, if any;  marks dispute ONSET";

. label variable cwdynm "Dyadic MID number (new number for each dyad-episode within each MID)";

. label variable cwhost1 "Relevant hostility level reached by cc1 in a MID vs. cc2 in this year";

. label variable cwhost2 "Relevant hostility level reached by cc2 in a MID vs. cc1 in this year";

. label variable cwhostd "Overall dispute hostility level (0 to 5, as in hostlev1)";

. label variable cwkeynum "Key MID number: Num of MID for which other MID variables are reported.  ";

. label variable cworig1 "cc1 is originator of the key MID, i.e. is involved on first day (0=no, 1=yes)";

. label variable cworig2 "cc2 is originator of the key MID (0=no, 1=yes)";

. label variable cwmidnme "Name of the MID identified in cwkeynum, if one has been designated by COW.";

. label variable cwstmo1 "MID start month for cc1";

. label variable cwstday1 "MID start day for cc1";

. label variable cwstyr1 "MID start year for cc1";

. label variable cwstmo2 "MID start month for cc2";

. label variable cwstday2 "MID start day for cc2";

. label variable cwstyr2 "MID start year for cc2";

. label variable cwendmo1 "MID end month for cc1";

. label variable cwenddy1 "MID end day for cc1";

. label variable cwendyr1 "MID end year for cc1";

. label variable cwendmo2 "MID end month for cc2";

. label variable cwenddy2 "MID end day for cc2";

. label variable cwendyr2 "MID end year for cc2";

. label variable cwrevt11 "Revision Type 1 for CCode1 (0=n/a, 1=territory, 2=policy, 3=regime, 4=other)";

. label variable cwrevt21 "Revision Type 2, State 1, when present in COW v3.0 data (missing pre 1992)";

. label variable cwrevt12 "Revision Type 1, State 2";

. label variable cwrevt22 "Revision Type 2, State 2, when present in COW v3.0 data.";

. label variable cwfatal1 "Fatality level for cc1";

. label variable cwfatex1 "Exact estimate of fatalities for cc1, if estimated in MID v3.0.";

. label variable cwfatal2 "Fatality level for cc2 (0 to 6, as in fatal1)";

. label variable cwfatex2 "Exact estimate of fatalities for cc2, if estimated in MID v3.0.";

. label variable cwhiact1 "Highest action by cc1 in dispute (see MID B codebook)";

. label variable cwhiact2 "Highest action by cc2 in dispute (see MID B codebook)";

. label variable cwhiactd "Highest action in dispute (see MID A codebook)";

. label variable cwoutcm "Overall dispute outcome (see MID A codebook)";

. label variable cwsettle "Overall MID settlement (1=negotiated, 2=imposed, 3=none, 4=unclear, -9=missing)";

. label variable cwfatald "Overall dispute fatality level (cow data)";

. label variable cwrecip "Reciprocated dispute (0=no, 1=yes)";

. label variable cwnumst1 "Num of states on cc1s side";

. label variable cwnumst2 "Num of states on cc2s side";

. label variable cwpceyrs "Peace Years, based on MIDs occurrence in COW dyadic MID set";

. compress;
milper_1 was float now int
milper_2 was float now int
distance was float now int
numGPs was int now byte
cwongo was int now byte
cwmid was int now byte
cwhost1 was int now byte
cwhost2 was int now byte
cwstmo1 was int now byte
cwstday1 was int now byte
cwstmo2 was int now byte
cwstday2 was int now byte
cwendmo1 was int now byte
cwenddy1 was int now byte
cwendmo2 was int now byte
cwenddy2 was int now byte
cwfatal1 was int now byte
cwfatex1 was int now byte
cwfatal2 was int now byte
cwfatex2 was int now byte
cwfatald was int now byte
cwnumst1 was int now byte
cwnumst2 was int now byte
democ1 was long now byte
democ2 was long now byte
autoc1 was long now byte
autoc2 was long now byte
polity1 was long now byte
polity2 was long now byte
polity21 was long now byte
polity22 was long now byte

. 
end of do-file

. 
. order ccode1 ccode2 year abbrev1 abbrev2 cwmid cwongo cwfatald polity21 polity22

. 
. *Dyadic Democracy Variables
. g dml=min(polity21, polity22) if polity21~=. & polity22~=.
(217644 missing values generated)

. label variable dml "DemocracyLow"

. g dmh=max(polity21, polity22) if polity21~=. & polity22~=.
(217644 missing values generated)

. label variable dmh "DemocracyHigh"

. 
. g mjpw=max(majpow1, majpow2) if majpow1~=. & majpow2~=.

. label variable mjpw "Major power"

. 
. 
. *contigl defined as contiguity by land
. g contigl=0 if contig~=1 & contig~=.
(130812 missing values generated)

. replace contigl=1 if contig==1
(20027 real changes made)

. label variable contigl "Land Contiguity"

. 
. 
. gen lndist=log(distance+1)

. 
. g cpl = cap_1 if cap_1 < cap_2 & cap_1~=. & cap_2~=.
(386134 missing values generated)

. replace cpl = cap_2 if cap_2 <= cap_1 & cap_1~=. & cap_2~=.
(367413 real changes made)

. g cph = cap_1 if cap_1 > cap_2 & cap_1~=. & cap_2~=.
(438591 missing values generated)

. replace cph = cap_2 if cap_2 >= cap_1 & cap_1~=. & cap_2~=.
(419870 real changes made)

. g lncprt=ln(cph/cpl) if cph~=. & cpl~=.
(21958 missing values generated)

. *drop cap_1 cap_2 cpl cph
. label variable lncprt "Relative capability"

. 
. *calculate probability of winning using CINCs*
. gen pwin_cap=cph/(cph+cpl)
(18729 missing values generated)

. 
. gen dyadid=(ccode1*1000)+ccode2

. 
. sort ccode1 ccode2 year

. order ccode1 ccode2 year abbrev1 abbrev2 cwmid cwongo cwfatald dyadid pwin_cap lncprt mjpw dml dmh contigl lndist

. 
. 
. **Dependent Variables
. sort dyadid year

. sort dyadid

. by dyadid: gen midonsl=cwmid[_n+1] 
(148973 missing values generated)

. by dyadid: replace midonsl=. if cwongo[_n+1]==1 & cwmid[_n+1]==0 
(1538 real changes made, 1538 to missing)

. label variable midonsl "MID onset lead"

. 
. sort dyadid year

. sort dyadid

. by dyadid: gen midongl=cwongo[_n+1] 
(148973 missing values generated)

. by dyadid: replace midongl=1 if cwmid[_n+1]==1
(2237 real changes made)

. label variable midongl "MID ongoing lead"

. *defining ongoing as onset or ongoing
. 
. sort dyadid year

. sort dyadid

. by dyadid: gen fmidonsl=1 if midonsl==1 & cwfatald[_n+1]>0 & cwfatald[_n+1]~=.
(804787 missing values generated)

. by dyadid: replace fmidonsl=0 if midonsl==0 | cwfatald[_n+1]==0 
(654357 real changes made)

. by dyadid: replace fmidonsl=. if fmidonsl[_n+1]==0 & cwfatald[_n+1]>0 
(470 real changes made, 470 to missing)

. label variable fmidons "Fatal MID onset lead"

. 
. sort dyadid year

. sort dyadid

. by dyadid: gen fmidongl=1 if midongl==1 & cwfatald[_n+1]>0 & cwfatald[_n+1]~=.
(803834 missing values generated)

. by dyadid: replace fmidongl=0 if midongl==0 | cwfatald[_n+1]==0 
(654357 real changes made)

. label variable fmidongl "Fatal MID ongoing lead"

. 
. sort dyadid year

. sort dyadid

. by dyadid: gen warl=1 if midongl==1 & cwfatald[_n+1]==6
(804324 missing values generated)

. by dyadid: replace warl=0 if midongl==0 | cwfatald[_n+1]<6 
(654847 real changes made)

. label variable warl "War ongoing lead"

. 
.  tab midonsl midongl, m

 MID onset |         MID ongoing lead
      lead |         0          1          . |     Total
-----------+---------------------------------+----------
         0 |   652,302          0          0 |   652,302 
         1 |         0      2,426          0 |     2,426 
         . |         0      1,538    148,973 |   150,511 
-----------+---------------------------------+----------
     Total |   652,302      3,964    148,973 |   805,239 


.   tab fmidonsl fmidongl, m

 Fatal MID |      Fatal MID ongoing lead
onset lead |         0          1          . |     Total
-----------+---------------------------------+----------
         0 |   654,101          0          0 |   654,101 
         1 |         0        238          0 |       238 
         . |       256      1,167    149,477 |   150,900 
-----------+---------------------------------+----------
     Total |   654,357      1,405    149,477 |   805,239 


.   tab warl fmidongl, m

       War |
   ongoing |      Fatal MID ongoing lead
      lead |         0          1          . |     Total
-----------+---------------------------------+----------
         0 |   654,357        490          0 |   654,847 
         1 |         0        915          0 |       915 
         . |         0          0    149,477 |   149,477 
-----------+---------------------------------+----------
     Total |   654,357      1,405    149,477 |   805,239 


.   
.   
.   
. ***Peace-years
. 
. drop if year<1950
(129940 observations deleted)

. drop if year>2001
(129121 observations deleted)

. 
. btscs midongl year dyadid, g(midyears)

. gen midyears2=midyears^2
(19241 missing values generated)

. gen midyears3=midyears^3
(19241 missing values generated)

. 
. btscs fmidongl year dyadid, g(fmidyears)

. gen fmidyears2=fmidyears^2
(19537 missing values generated)

. gen fmidyears3=fmidyears^3
(19537 missing values generated)

. 
. btscs warl year dyad, g(waryears)

. gen waryears2=waryears^2
(19537 missing values generated)

. gen waryears3=waryears^3
(19537 missing values generated)

. 
. 
. *drop country_name1 country_name2
. kountry ccode1, from(cown)

----------------------------------------
The command has finished.
The new variable is named NAMES_STD.
----------------------------------------

. rename NAMES_STD country_name1

.  
. kountry ccode2, from(cown) 

----------------------------------------
The command has finished.
The new variable is named NAMES_STD.
----------------------------------------

. rename NAMES_STD country_name2

. 
. 
. order country_name*

. save "12-05-28_dem_CIE_analysis.dta", replace
file 12-05-28_dem_CIE_analysis.dta saved

. 
. **Produce "country_year_mimpute.dta"
. do "12-06-11_country_year.do"

. **Setting up Country Year Data
. clear 

. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. *cd "/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/Mousseau_Replication_Files/"
. *"MIDB_310.dta" from CoW website: http://www.correlatesofwar.org/COW2%20Data/MIDs/MID310.html
. 
. use "MIDB_310.dta"

. keep dispnum stabb ccode sidea fatality hiact hostlev orig styear endyear

. sort ccode

. gen lengthyears=endyear-styear

. 
. gen dispnumccode=dispnum*1000+ccode

. 
. sort dispnumccode

. order dispnumccode lengthyears

. 
. ssc install expandby 
checking expandby consistency and verifying not already installed...
all files already exist and are up to date.

. 
. local i=2

. while `i' <=50 {
  2. expandby `i' if lengthyears==`i'-1, by(dispnumccode)
  3. local i=`i'+1
  4. } 
(1030 observations created)
(366 observations created)
(288 observations created)
(192 observations created)
(100 observations created)
(72 observations created)
(35 observations created)
(48 observations created)
(9 observations created)
(0 observations created)
(88 observations created)
(0 observations created)
(39 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)
(0 observations created)

. 
. sort dispnumccode

. 
. by dispnumccode: gen year=styear+_n-1

. drop styear endyear

. 
. gen fmid=1 if fatality>0 & fatality<7
(6077 missing values generated)

. replace fmid=0 if fatality==0
(4988 real changes made)

. 
. gen war=1 if fatality==6
(7273 missing values generated)

. replace war=0 if fatality<6
(7273 real changes made)

. 
. ***Caution: Imputation Assumption****
. **Simple imputation: imputing missing data on fatality to 0. 
. replace fmid=0 if fatality==-9
(1089 real changes made)

. ***********
. 
. **Generate count of MIDs, fMIDs and Wars per country year
. sort ccode year

. by ccode year: egen midC=count(dispnum)

. by ccode year: egen fmidC=total(fmid)

. by ccode year: egen warC=total(war)

. 
. drop fmid war

. rename midC mid

. rename fmidC fmid

. rename warC war

. 
. by ccode year: gen last=1 if _n==_N
(3592 missing values generated)

. keep if last==1
(3592 observations deleted)

. drop last dispnumccode lengthyears dispnum hiact hostlev orig fatality sidea

. 
. sort ccode year

. save "country_year_MID.dta", replace
file country_year_MID.dta saved

. 
. ************
. 
. 
. ***
. **Code from "CINE Data Replication Do File.do"
. 
. clear 

. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. *cd "/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/Mousseau_Replication_Files/"
. *"raw for replication.dta" provided by Michael Mousseau on Jan 4th, 2012, as well as all files in folder "CINE_Data"
. use "CINE_Data/raw for replication.dta"

. 
. **Start MM Code**
. replace         rgdpl=.          if     rgdpl    ==     -99
(590 real changes made, 590 to missing)

. replace         openk=.          if     openk    ==     -99
(580 real changes made, 580 to missing)

. replace         kc=.             if     kc               ==     -99
(590 real changes made, 590 to missing)

. replace         kg=.             if     kg               ==     -99
(590 real changes made, 590 to missing)

. replace         ki=.             if     ki               ==     -99
(590 real changes made, 590 to missing)

. replace         energy=.         if     energy   ==     -9
(32 real changes made, 32 to missing)

. replace         tpop=.           if     tpop     ==     -9
(1 real change made, 1 to missing)

. 
. 
. *apparent errors in the data; nations in major transitions:
. replace ki=. if ccode==315 & year==1992 | ccode==365 & year==1990 | ccode==365 & year==1991 |  ccode==366 & year==1991 | ccode==690 & ye
> ar==1991
(5 real changes made, 5 to missing)

. replace kc=. if ccode==690 & year==1991
(1 real change made, 1 to missing)

. replace kg=. if ccode==690 & year==1991
(1 real change made, 1 to missing)

. replace openk=. if ccode==690 & year==1991
(1 real change made, 1 to missing)

. 
. ************
. g CIE = ln(lifedeer+1)
(4751 missing values generated)

. drop lifedeer

. 
. 
. rename kc kcpct

. rename ki kipct

. rename kg kgpct

. rename openk ktpct

. g kc=(kcpct/100)*rgdpl
(785 missing values generated)

. g ki=(kipct/100)*rgdpl
(789 missing values generated)

. g kg=(kgpct/100)*rgdpl
(785 missing values generated)

. g kt=(ktpct/100)*rgdpl
(785 missing values generated)

. g kitokt=ki/kt
(789 missing values generated)

. g kctokt=kc/kt
(785 missing values generated)

. 
. g lnrgdpl=ln(rgdpl)
(784 missing values generated)

. drop rgdpl

. g lnfood=ln(food)
(6051 missing values generated)

. g enrpc=energy/tpop
(32 missing values generated)

. g lnenrpc=ln(enrpc+1)
(32 missing values generated)

. drop energy

. 
. g imputed=0

. replace imputed=1 if CIE==.
(4751 real changes made)

. 
. recode region1 (1=1 "West")             (2/5=0 "Other")                                 (.=.), gen(rwest)
(4967 differences between region1 and rwest)

. recode region1 (2=1 "Middle East") (1=0 "Other")        (3/5=0 "Other") (.=.), gen(rmideast)
(6311 differences between region1 and rmideast)

. recode region1 (3=1 "Africa")           (1/2=0 "Other") (4/5=0 "Other") (.=.), gen(rafrica)
(6311 differences between region1 and rafrica)

. recode region1 (4=1 "Asia")             (1/3=0 "Other") (5=0 "Other")   (.=.), gen(rasia)
(6311 differences between region1 and rasia)

. recode region1 (5=1 "America")  (1/4=0 "Other")                                 (.=.), gen(rameri)
(6311 differences between region1 and rameri)

. drop region1

. 
. g cmmst=0

. replace cmmst =1 if year < 1992 & (ccode == 339  | ccode == 345  | ccode == 355  | ccode == 710  | ccode == 40  | ccode ==315  | ccode =
> = 265 | ccode == 310  | ccode == 812  | ccode == 712  | ccode == 731  | ccode == 290 | ccode == 360 | ccode == 365 | ccode == 816)
(479 real changes made)

. replace cmmst=1 if ccode==731
(9 real changes made)

. 
. g pcom=0                

. replace pcom=1 if year >1991 & (ccode== 40 |ccode== 290 |ccode== 310 |ccode== 316 |ccode== 317 |ccode== 331 |ccode== 338 |ccode== 339 |c
> code== 343 |ccode== 344 |ccode== 345 |ccode== 346 |ccode== 349 |ccode== 355 |ccode== 359 |ccode== 360 |ccode== 365 |ccode== 366 |ccode==
>  367 |ccode== 368 |ccode== 369 |ccode== 370 |ccode== 371 |ccode== 372 |ccode== 373 |ccode== 700 |ccode== 701 |ccode== 702 |ccode== 703 |
> ccode== 704 |ccode== 705 |ccode== 710 |ccode== 712 |ccode== 812 |ccode== 816) 
(312 real changes made)

. 
. g micro=0

. replace micro=ln(0-tpop+1001) if tpop<1000
(1073 real changes made)

. replace micro=. if tpop==.
(1 real change made, 1 to missing)

. 
. g y7980=0

. g y8185=0

. g y86=0

. g y8791=0

. g y92=0

. g y9398=0

. g y9900=0

. replace y7980=1         if year >=1979 & year<=1980
(312 real changes made)

. replace y8185=1         if year >=1981 & year<=1985
(800 real changes made)

. replace y86=1           if year >=1986 & year<=1986
(161 real changes made)

. replace y8791=1         if year >=1987 & year<=1991
(824 real changes made)

. replace y92=1           if year >=1992 & year<=1992
(181 real changes made)

. replace y9398=1         if year >=1993 & year<=1998
(1121 real changes made)

. replace y9900=1         if year >=1999 & year<=2000
(381 real changes made)

. 
. g       num6069=1959

. replace num6069=year    if year>=1960 & year <1970
(1226 real changes made)

. g       num7174=1970

. replace num7174=year    if year>=1971 & year==1974
(143 real changes made)

. g       num7583=1974

. replace num7583=year    if year>=1975 & year<=1983
(1397 real changes made)

. g       num8488=0

. replace num8488=1               if year>=1984 & year<=1988
(805 real changes made)

. g       num89=0

. replace num89=1                 if year==1989
(161 real changes made)

. g       num9091=0       

. replace num9091=1               if year==1990
(164 real changes made)

. replace num9091=2               if year==1991
(177 real changes made)

. g       num92=0         

. replace num92=1                 if year==1992
(181 real changes made)

. g       num9394=0

. replace num9394=1               if year==1993
(186 real changes made)

. replace num9394=2               if year==1994
(187 real changes made)

. g       num9598=0

. replace num9598=1               if year>=1995 & year<=  1998
(748 real changes made)

. g       num99=0

. replace num99=1                 if year==1999
(190 real changes made)

. g       num00=0

. replace num00=1                 if year==2000
(191 real changes made)

. **END MM Code**
. rename CIE MMCIE

. 
. keep ccode year MMCIE enrpc lnenrpc ki kc kitokt kctokt oil pcom cmmst tpop micro rmideast year y7980 y8185 y86 y8791 y92 y9398 y9900 nu
> m6069 num7174 num7583 num8488 num89 num9091 num9394 num9598 num99 num00

. 
. 
. 
. **MM's imputation variables: CIE enrpc lnenrpc ki kc kitokt kctokt oil pcom cmmst tpop micro rmideast year y7980 y8185 y86 y8791 y92 y93
> 98 y9900 num6069 num7174 num7583 num8488 num89 num9091 num9394 num9598 num99 num00
. **MM's impute command: impute CIE enrpc lnenrpc ki kc kitokt kctokt oil pcom cmmst tpop micro rmideast year y7980 y8185 y86 y8791 y92 y9
> 398 y9900 num6069 num7174 num7583 num8488 num89 num9091 num9394 num9598 num99 num00, g (iCIE)
. 
. sort ccode year

. save "MM_CIE_impute_raw.dta", replace
file MM_CIE_impute_raw.dta saved

. *****
. 
. 
. 
. *Gleditsch Trade and GDP data country-year
. clear

. *Downloaded from here: http://privatewww.essex.ac.uk/~ksg/exptradegdp.html
. insheet using "Other_files/exptradegdpv4.1 2/expdata.asc", delimiter(" ")
(23 vars, 579229 obs)

. sort numa year

. by numa year: gen last=1 if _n==_N
(571649 missing values generated)

. 
. sort numb year

. by numb year: gen last2=1 if _n==_N
(571649 missing values generated)

. tab last last2, m

           |         last2
      last |         1          . |     Total
-----------+----------------------+----------
         1 |        90      7,490 |     7,580 
         . |     7,490    564,159 |   571,649 
-----------+----------------------+----------
     Total |     7,580    571,649 |   579,229 


. 
. gen ccode = numa if last==1
(571649 missing values generated)

. replace ccode= numb if last2==1
(7580 real changes made)

. 
. order ccode numa numb last*

. keep if last==1 | last2==1
(564159 observations deleted)

. drop last*

. sort ccode year

. by ccode year: gen duplicate=1 if _n>1
(7633 missing values generated)

. 
. gen gdppc=rgdpca if ccode==numa
(7742 missing values generated)

. replace gdppc=rgdpcb if ccode==numb
(7414 real changes made)

. 
. gen pop=popa if ccode==numa
(7742 missing values generated)

. replace pop=popb if ccode==numb
(7414 real changes made)

. 
. gen tottr=tottra if ccode==numa
(7580 missing values generated)

. replace tottr=tottrb if ccode==numb
(7580 real changes made)

. 
. 
. order ccode year gdppc numa numb rgdp*

. drop if duplicate~=.
(7437 observations deleted)

. 
. keep ccode year gdppc pop tottr

. sort ccode year

. save "gleditsch_country_year.dta", replace
file gleditsch_country_year.dta saved

. 
. 
. *acra/b         Three letter acronym for state A/B      
. *numa/b         Numeric id code for state A/B
. *year           Year
. *expab          Export A to B
. *eabo           Export A to B origin code
. *impab          Import A from B
. *iabo           Import A from B origin code
. *expba          Export B to A           
. *ebao           Export B to A origin code
. *impba          Import B from A 
. *ibao           Import B from A origin code
. *popa           Population of A
. *rgdpca/b       Real GDP per capita of A/B
. *cgdpca/b       Current GDP per capita of A/B
. *goa/b          Origin of GDP per capita estimate A/B
. *tottra/b       Total trade for country A/B
. 
. 
. 
. 
. 
. 
. 
. 
. ******************
. clear

. 
. cd "$filetree"
/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/DOR_ISQ_2013_Replication/M_Rep

. *cd "/Users/Allan/Dropbox/!!Papers/Liberal Peace/12-02-21_ISQ_commentary/Mousseau_Replication_Files/"
. do "Eugene/country_year.out.do"

. * STATA command file generated by EUGene  3.20 to read data file
. * "C:\Program Files\EUGene\country_year.out"
. * To execute this command file: 
. *    1) Run STATA,
. *    2) "cd" to directory "C:\Program Files\EUGene\",
. *    3) enter command "do country_year.out.do".
. 
. * Number of observations in this data set: 14393
. 
. * Data set specifications:
. *   Base Format: Country-Year
. *   Time Span: 1816 to 2008
. *   Selected Subset: All states included
. *   Sampling: None (100% of available data written to file)
. *   Variables included:
. *        ccode  year    abbrev  cap     milper  milex   energy  irst    upop    tpop    majpow  region1 democ   autoc   dem     numstate
>         numGPs  syscon  sysmove1        sysmove5        sysmvGP1        sysmvGP5        country imports exports alt_imports     alt_expo
> rts     source1 source2 version cyear   scode   countr01        flag    fragment        democ   autoc   polity  polity2 durable xrreg   
> xrcomp  xropen  xconst  parreg  parcomp exrec   exconst polcomp prior   emonth  eday    eyear   eprec   interim bmonth  bday    byear   
> bprec   post    change  d4      sf      regtrans        versio01
. *   Selected settings for variables with multiple output options:
. *        Peace years calculated without Werner peace year adjustment
. *        No complex variables selected
. 
. * Note:  EUGene draws on datasets originally published elsewhere by other scholars.  When 
. * presenting analysis using data generated by EUGene, please cite the original data sources 
. * as well as EUGene (see EUGene documentation, Appendix D) 
. *
. * Bibliography for this data set:
. * Jaggers, Keith, and Ted Robert Gurr.  1995.  "Tracking Democracy's Third Wave with the Polity III Data."  Journal of Peace Research 32
> :469-482.
. * Small, Melvin, and J. David Singer.  1969.  "Formal Alliances, 1815-1965:  An Extension of the Basic Data."  Journal of Peace Research
>  6: 257-282.  
. * Werner, Suzanne.  2000.  "The Effects of Political Similarity on the Onset of Militarized Disputes, 1816-1985."  Political Research Qu
> arterly 53(2): 343-374.
. * Correlates of War Project. 2008. �Trade Data Set, v2.0.� Online, http://correlatesofwar.org
. * Marshall, Monty G. and Keith Jaggers. 2002. Polity IV Project: Political Regime Characteristics and Transitions, 1800-2002. http://www
> .cidcm.umd.edu/inscr/polity/index.htm.
. 
. 
. clear 

. 
. infile int ccode int year str3 abbrev float cap float milper float milex float energy float irst float upop float tpop byte majpow byte 
> region1 byte democ1 byte autoc1 byte dem int numstate int numGPs float syscon float sysmove1 float sysmove5 float sysmvGP1 float sysmvGP
> 5 str32 country float imports float exports float alt_imports float alt_exports long source1 long source2 float version long cyear str32
>  scode str32 countr01 long flag long fragment long democ2 long autoc2 long polity long polity2 long durable long xrreg long xrcomp long 
> xropen long xconst long parreg long parcomp long exrec long exconst long polcomp long prior long emonth long eday long eyear long eprec 
> long interim long bmonth long bday long byear long bprec long post long change long d4 long sf long regtrans float versio01  using "Euge
> ne/country_year.out" 
'ccode' cannot be read as a number for ccode[1]
'year' cannot be read as a number for year[1]
'cap' cannot be read as a number for cap[1]
'milper' cannot be read as a number for milper[1]
'milex' cannot be read as a number for milex[1]
'energy' cannot be read as a number for energy[1]
'irst' cannot be read as a number for irst[1]
'upop' cannot be read as a number for upop[1]
'tpop' cannot be read as a number for tpop[1]
'majpow' cannot be read as a number for majpow[1]
'region1' cannot be read as a number for region1[1]
'democ' cannot be read as a number for democ1[1]
'autoc' cannot be read as a number for autoc1[1]
'dem' cannot be read as a number for dem[1]
'numstate' cannot be read as a number for numstate[1]
'numGPs' cannot be read as a number for numGPs[1]
'syscon' cannot be read as a number for syscon[1]
'sysmove1' cannot be read as a number for sysmove1[1]
'sysmove5' cannot be read as a number for sysmove5[1]
'sysmvGP1' cannot be read as a number for sysmvGP1[1]
'sysmvGP5' cannot be read as a number for sysmvGP5[1]
'imports' cannot be read as a number for imports[1]
'exports' cannot be read as a number for exports[1]
'alt_imports' cannot be read as a number for alt_imports[1]
'alt_exports' cannot be read as a number for alt_exports[1]
'source1' cannot be read as a number for source1[1]
'source2' cannot be read as a number for source2[1]
'version' cannot be read as a number for version[1]
'cyear' cannot be read as a number for cyear[1]
'flag' cannot be read as a number for flag[1]
'fragment' cannot be read as a number for fragment[1]
'democ' cannot be read as a number for democ2[1]
'autoc' cannot be read as a number for autoc2[1]
'polity' cannot be read as a number for polity[1]
'polity2' cannot be read as a number for polity2[1]
'durable' cannot be read as a number for durable[1]
'xrreg' cannot be read as a number for xrreg[1]
'xrcomp' cannot be read as a number for xrcomp[1]
'xropen' cannot be read as a number for xropen[1]
'xconst' cannot be read as a number for xconst[1]
'parreg' cannot be read as a number for parreg[1]
'parcomp' cannot be read as a number for parcomp[1]
'exrec' cannot be read as a number for exrec[1]
'exconst' cannot be read as a number for exconst[1]
'polcomp' cannot be read as a number for polcomp[1]
'prior' cannot be read as a number for prior[1]
'emonth' cannot be read as a number for emonth[1]
'eday' cannot be read as a number for eday[1]
'eyear' cannot be read as a number for eyear[1]
'eprec' cannot be read as a number for eprec[1]
'interim' cannot be read as a number for interim[1]
'bmonth' cannot be read as a number for bmonth[1]
'bday' cannot be read as a number for bday[1]
'byear' cannot be read as a number for byear[1]
'bprec' cannot be read as a number for bprec[1]
'post' cannot be read as a number for post[1]
'change' cannot be read as a number for change[1]
'd4' cannot be read as a number for d4[1]
'sf' cannot be read as a number for sf[1]
'regtrans' cannot be read as a number for regtrans[1]
'versio01' cannot be read as a number for versio01[1]
(14394 observations read)

. 
. * The next command drops the case that was read 
. *  if the user included a line of variable names 
. 
. drop if missing(ccode) | missing(year) 
(1 observation deleted)

. 
. * Interpret missing values  
. mvdecode ccode year abbrev cap milper milex energy irst upop tpop majpow region1 numstate numGPs syscon sysmove1 sysmove5 sysmvGP1 sysmv
> GP5 , mv(-9) 
      abbrev: string variable ignored
         cap: 194 missing values generated
      milper: 584 missing values generated
       milex: 2166 missing values generated
      energy: 613 missing values generated
        irst: 281 missing values generated
        upop: 264 missing values generated
        tpop: 220 missing values generated
      syscon: 194 missing values generated
    sysmove1: 194 missing values generated
    sysmove5: 92 missing values generated
    sysmvGP1: 194 missing values generated
    sysmvGP5: 286 missing values generated

. mvdecode democ1 autoc1 dem , mv(-99) 
      democ1: 3426 missing values generated
      autoc1: 3426 missing values generated
         dem: 3426 missing values generated

. mvdecode democ1 autoc1 dem , mv(-88) 
      democ1: 258 missing values generated
      autoc1: 258 missing values generated
         dem: 258 missing values generated

. mvdecode democ1 autoc1 dem , mv(-77) 
      democ1: 102 missing values generated
      autoc1: 102 missing values generated
         dem: 102 missing values generated

. mvdecode democ1 autoc1 dem , mv(-66) 
      democ1: 57 missing values generated
      autoc1: 57 missing values generated
         dem: 57 missing values generated

. mvdecode democ2 autoc2, mv(-99) 
      democ2: 1863 missing values generated
      autoc2: 1863 missing values generated

. mvdecode democ2 autoc2, mv(-88) 
      democ2: 291 missing values generated
      autoc2: 291 missing values generated

. mvdecode democ2 autoc2, mv(-77) 
      democ2: 151 missing values generated
      autoc2: 151 missing values generated

. mvdecode democ2 autoc2, mv(-66) 
      democ2: 102 missing values generated
      autoc2: 102 missing values generated

. mvdecode country, mv(-9) 
     country: string variable ignored

. mvdecode imports, mv(-9) 
     imports: 2786 missing values generated

. mvdecode exports, mv(-9) 
     exports: 2786 missing values generated

. mvdecode alt_imports, mv(-9) 
 alt_imports: 14291 missing values generated

. mvdecode alt_exports, mv(-9) 
 alt_exports: 14291 missing values generated

. mvdecode source1, mv(-9) 
     source1: 2409 missing values generated

. mvdecode source2, mv(-9) 
     source2: 2409 missing values generated

. mvdecode version, mv(-9) 
     version: 2247 missing values generated

. mvdecode cyear, mv(-99) 
       cyear: 1863 missing values generated

. mvdecode scode, mv(-99) 
       scode: string variable ignored

. mvdecode countr01, mv(-99) 
    countr01: string variable ignored

. mvdecode flag, mv(-99) 
        flag: 1863 missing values generated

. mvdecode fragment, mv(-99) 
    fragment: 13568 missing values generated

. mvdecode democ2, mv(-99) 

. mvdecode autoc2, mv(-99) 

. mvdecode polity, mv(-99) 
      polity: 1863 missing values generated

. mvdecode polity2, mv(-99) 
     polity2: 1980 missing values generated

. mvdecode durable, mv(-99) 
     durable: 2262 missing values generated

. mvdecode xrreg, mv(-99) 
       xrreg: 1863 missing values generated

. mvdecode xrcomp, mv(-99) 
      xrcomp: 1863 missing values generated

. mvdecode xropen, mv(-99) 
      xropen: 1863 missing values generated

. mvdecode xconst, mv(-99) 
      xconst: 1863 missing values generated

. mvdecode parreg, mv(-99) 
      parreg: 1863 missing values generated

. mvdecode parcomp, mv(-99) 
     parcomp: 1863 missing values generated

. mvdecode exrec, mv(-99) 
       exrec: 1999 missing values generated

. mvdecode exconst, mv(-99) 
     exconst: 1863 missing values generated

. mvdecode polcomp, mv(-99) 
     polcomp: 1901 missing values generated

. mvdecode prior, mv(-99) 
       prior: 13327 missing values generated

. mvdecode emonth, mv(-99) 
      emonth: 13276 missing values generated

. mvdecode eday, mv(-99) 
        eday: 13276 missing values generated

. mvdecode eyear, mv(-99) 
       eyear: 13276 missing values generated

. mvdecode eprec, mv(-99) 
       eprec: 13276 missing values generated

. mvdecode interim, mv(-99) 
     interim: 13532 missing values generated

. mvdecode bmonth, mv(-99) 
      bmonth: 13459 missing values generated

. mvdecode bday, mv(-99) 
        bday: 13459 missing values generated

. mvdecode byear, mv(-99) 
       byear: 13459 missing values generated

. mvdecode bprec, mv(-99) 
       bprec: 13459 missing values generated

. mvdecode post, mv(-99) 
        post: 13467 missing values generated

. mvdecode change, mv(-99) 
      change: 12832 missing values generated

. mvdecode d4, mv(-99) 
          d4: 13444 missing values generated

. mvdecode sf, mv(-99) 
          sf: 14203 missing values generated

. mvdecode regtrans, mv(-99) 
    regtrans: 12829 missing values generated

. mvdecode versio01, mv(-99) 
    versio01: 1863 missing values generated

. 
. * Variable labels where available (see EUGeneDocumentation.doc for full information)  
. label variable democ1 "Jaggers and Gurr (1995) Polity III Democracy Score for CCode" 

. label variable autoc1 "Polity III Autocracy Score for CCode" 

. label variable dem "Democracy Score for CCode (democ-autoc)" 

. label variable ccode "Correlates of War (COW) CCode Num for state" 

. label variable year "Year of observation" 

. label variable abbrev "Country Abbreviation" 

. label variable cap "National Capabilities Index (CINC) for CCode" 

. label variable milper "COW military personnel for CCode" 

. label variable milex "COW military expenditure for CCode" 

. label variable energy "COW energy production for CCode" 

. label variable irst "COW iron/steel production for CCode" 

. label variable upop "COW nominal urban population for CCode" 

. label variable tpop "COW nominal total population for CCode" 

. label variable majpow "Major power status of CCode" 

. label variable region1 "Home region of cc1" 

. label variable numstate "Number of states in intl system as defined by COW system membership" 

. label variable numGPs "Num of great powers in the international system" 

. label variable syscon "System concentration (CON), entire system" 

. label variable sysmove1 "System movement (MOVE), yearly computation, entire system" 

. label variable sysmove5 "System movement (MOVE), 5-year moving average, entire system" 

. label variable sysmvGP1 "System movement (MOVE), yearly computation, great powers" 

. label variable sysmvGP5 "System movement (MOVE), 5-year moving average, great powers" 

. 
. compress 
milper was float now int
numGPs was int now byte
source1 was long now byte
source2 was long now byte
version was float now byte
flag was long now byte
fragment was long now byte
democ2 was long now byte
autoc2 was long now byte
polity was long now byte
polity2 was long now byte
durable was long now int
xrreg was long now byte
xrcomp was long now byte
xropen was long now byte
xconst was long now byte
parreg was long now byte
parcomp was long now byte
exrec was long now byte
exconst was long now byte
polcomp was long now byte
prior was long now byte
emonth was long now byte
eday was long now byte
eyear was long now int
eprec was long now byte
interim was long now byte
bmonth was long now byte
bday was long now byte
byear was long now int
bprec was long now byte
post was long now byte
change was long now byte
d4 was long now byte
sf was long now byte
regtrans was long now byte
scode was str32 now str3
countr01 was str32 now str24

. 
end of do-file

. 
. sort ccode year

. 
. **Importing MID data
. merge 1:1 ccode year using "country_year_MID.dta"
year was int now float

    Result                           # of obs.
    -----------------------------------------
    not matched                        10,116
        from master                    10,116  (_merge==1)
        from using                          0  (_merge==2)

    matched                             4,277  (_merge==3)
    -----------------------------------------

. drop _merge

. replace mid=0 if mid==.
(10116 real changes made)

. replace fmid=0 if fmid==.
(10116 real changes made)

. replace war=0 if war==.
(10116 real changes made)

. 
. 
. sort ccode year

. merge 1:1 ccode year using "gleditsch_country_year.dta"
ccode was int now float

    Result                           # of obs.
    -----------------------------------------
    not matched                         7,560
        from master                     7,160  (_merge==1)
        from using                        400  (_merge==2)

    matched                             7,233  (_merge==3)
    -----------------------------------------

. drop if _merge==2 
(400 observations deleted)

. *these seem to all be small countries
. drop _merge

. 
. rename ccode ccode1

. rename year year1

. sort ccode1 year1

. merge 1:1 ccode year using "beck_webb1.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                        12,085
        from master                    11,859  (_merge==1)
        from using                        226  (_merge==2)

    matched                             2,534  (_merge==3)
    -----------------------------------------

. *browse if _merge==2
. drop if _merge==2
(226 observations deleted)

. drop _merge

. 
. rename ccode1 ccode

. rename year1 year

. 
. sort ccode year

. merge 1:1 ccode year using "MM_CIE_impute_raw.dta"
tpop was float now double

    Result                           # of obs.
    -----------------------------------------
    not matched                         8,082
        from master                     8,082  (_merge==1)
        from using                          0  (_merge==2)

    matched                             6,311  (_merge==3)
    -----------------------------------------

. *browse if _merge==2
. drop if _merge==2
(0 observations deleted)

. drop _merge

. 
. 
. *********M. Impute data**********
. 
. **If you don't have it, install mvpatterns by typing: findit mvpatterns
. mvpatterns pop tpop
Variable     | type     obs   mv   variable label
-------------+-----------------------------------------------------------
pop          | float   7086 7307   
tpop         | double 14173  220   COW nominal total population for CCode
-------------------------------------------------------------------------

Patterns of missing values

  +------------------------+
  | _pattern   _mv   _freq |
  |------------------------|
  |       .+     1    7087 |
  |       ++     0    7086 |
  |       ..     2     220 |
  +------------------------+

. *cow population data (tpop) much more comprehensive
. 
. order ccode abbrev year mid fmid war gdppc cap milper milex irst energy upop tpop numstate numGPs majpow region1 polity2 xrreg xrcomp xr
> open xconst tottr lifepen1 acli1 income1 lifedens1 lifedeer1 lifeexp1 MMCIE enrpc lnenrpc ki kc kitokt kctokt oil pcom cmmst tpop micro 
> rmideast year y7980 y8185 y86 y8791 y92 y9398 y9900 num6069 num7174 num7583 num8488 num89 num9091 num9394 num9598 num99 num00

. 
. sort ccode year

. keep  ccode abbrev year mid fmid war gdppc cap milper milex irst energy upop tpop numstate numGPs majpow region1 polity2 tottr lifepen1 
> acli1 lifedens1 lifedeer1 lifeexp1 MMCIE enrpc lnenrpc ki kc kitokt kctokt oil pcom cmmst tpop micro rmideast year y7980 y8185 y86 y8791
>  y92 y9398 y9900 num6069 num7174 num7583 num8488 num89 num9091 num9394 num9598 num99 num00

. 
. ***Warning: dropping observations missing values on some variables
. drop if mid==. | cap==. | polity2==. | energy==. | upop==. | tpop==. | ccode==. 
(2374 observations deleted)

. *about 2400 observations dropped
. 
. *Evaluating distribution of variables, consider transformations to make them more normal
. *See p11 of Amelia II documentation
. 
. *hist gdppc
. gen lngdppc=log(gdppc)
(5578 missing values generated)

. *scatter gdppc lngdppc
. drop gdppc

. *hist cap
. gen lncap=log(cap)

. *scatter lncap cap
. *hist lncap
. *hist milper
. gen lnmilper=log(milper)
(644 missing values generated)

. *hist milex
. gen lnmilex=log(milex)
(1483 missing values generated)

. *amazingly normally distributed
. *hist irst
. gen lnirst=log(irst)
(6464 missing values generated)

. *hist energy
. gen lnenergy=log(energy)
(1245 missing values generated)

. *hist upop
. gen lnupop=log(upop)
(1752 missing values generated)

. *hist tpop
. gen lntpop=log(tpop)

. *again, amazing
. *hist numstate
. *hist numGPs
. *hist majpow
. *hist polity2 
. label variable tottr "Total Trade Gleditsch"

. *hist tottr
. gen lntottr=log(tottr)
(5438 missing values generated)

. 
. *hist lifepen1
. gen lnlifepen=log(lifepen1)
(10423 missing values generated)

. *scatter lifepen1 lnlifepen
. *hist lnlifepen
. 
. *hist acli1
. gen lnacli=log(acli1)
(10938 missing values generated)

. *hist lifedens1
. gen lnlifedens=log(lifedens1)
(10593 missing values generated)

. *hist lifedeer1
. *+1 to look like MM's measure
. gen lnlifedeer=log(lifedeer1+1)
(10413 missing values generated)

. *hist lifeexp1
. 
. order ccode abbrev year mid fmid war numstate numGPs majpow region1 polity2 ln*

. label variable polity2 "Polity IV Dem-Aut Score"

. label variable mid "Onset or Ongoing MID"

. label variable fmid "Onset or Ongoing Fatal MID"

. label variable war "Onset or Ongoing War"

. label variable lngdppc "Ln Real GDP per capita"

. label variable lnlifedeer "Ln Life Insurance Density"

. label variable lnlifedens "Ln Life Insurance Density PPP"

. label variable lncap "Ln National Capabilities Index"

. label variable lnmilper "Ln COW military personnel"

. label variable lnmilex "Ln COW military expenditure"

. label variable lnirst "Ln COW iron/steel production"

. label variable lnenergy "Ln COW energy production"

. label variable lnupop "Ln COW urban population"

. label variable lntpop "Ln COW total population"

. label variable lntottr "Ln Total Trade Gleditsch"

. label variable lnlifepen "Ln Life Insurance Penetration"

. label variable lnacli "Ln Life Insurance in Force to GDP"

. 
. *scatter lnlifedeer MMCIE
. 
. keep ccode abbrev year mid fmid war numstate numGPs majpow region1 polity2 ln* MMCIE enrpc lnenrpc ki kc kitokt kctokt oil pcom cmmst tp
> op micro rmideast year y7980 y8185 y86 y8791 y92 y9398 y9900 num6069 num7174 num7583 num8488 num89 num9091 num9394 num9598 num99 num00

. 
. drop lnlifedens

. drop if year<1950
(4936 observations deleted)

. drop if year>2001
(463 observations deleted)

. rename region1 region

. 
. **Updating MM's temporal variables
. drop y7980 y8185 y86 y8791 y92 y9398 y9900 num6069 num7174 num7583 num8488 num89 num9091 num9394 num9598 num99 num00

. 
. g y7980=0

. g y8185=0

. g y86=0

. g y8791=0

. g y92=0

. g y9398=0

. g y9900=0

. replace y7980=1         if year >=1979 & year<=1980
(279 real changes made)

. replace y8185=1         if year >=1981 & year<=1985
(700 real changes made)

. replace y86=1           if year >=1986 & year<=1986
(140 real changes made)

. replace y8791=1         if year >=1987 & year<=1991
(715 real changes made)

. replace y92=1           if year >=1992 & year<=1992
(156 real changes made)

. replace y9398=1         if year >=1993 & year<=1998
(950 real changes made)

. replace y9900=1         if year >=1999 & year<=2000
(315 real changes made)

. 
. g       num6069=1959

. replace num6069=year    if year>=1960 & year <1970
(1182 real changes made)

. g       num7174=1970

. replace num7174=year    if year>=1971 & year==1974
(136 real changes made)

. g       num7583=1974

. replace num7583=year    if year>=1975 & year<=1983
(1258 real changes made)

. g       num8488=0

. replace num8488=1               if year>=1984 & year<=1988
(701 real changes made)

. g       num89=0

. replace num89=1                 if year==1989
(140 real changes made)

. g       num9091=0       

. replace num9091=1               if year==1990
(141 real changes made)

. replace num9091=2               if year==1991
(153 real changes made)

. g       num92=0         

. replace num92=1                 if year==1992
(156 real changes made)

. g       num9394=0

. replace num9394=1               if year==1993
(159 real changes made)

. replace num9394=2               if year==1994
(159 real changes made)

. g       num9598=0

. replace num9598=1               if year>=1995 & year<=  1998
(632 real changes made)

. g       num99=0

. replace num99=1                 if year==1999
(158 real changes made)

. g       num00=0

. replace num00=1                 if year==2000
(157 real changes made)

. 
. gen lngdppcsq=lngdppc^2 
(179 missing values generated)

. gen lngdppccube=lngdppc^3
(179 missing values generated)

. 
. gen polity2sq=polity2^2

. gen polity2cube=polity2^3

. 
. saveold "country_year_mimpute.dta", replace
file country_year_mimpute.dta saved

. 
. 
. **See R code for multiple imputation***
. *AD: I opted to use Amelia II because it had a convenient technique for having within country temporal trends.
. *R code creates files: "outdatatotal1.dta" and other files with increasing numbers for each imputation
. 
. 
. 
. 
end of do-file

. 
. 
. **See R code "MI_Dem_CIE.r" for multiple imputation***
. *AD: I opted to use Amelia II because it had a convenient technique for having within country temporal trends.
. *R code creates files: "outdatatotal1.dta" and other files with increasing numbers for each imputation
. ***
. 
. 
end of do-file

.         *calls: "12-06-11_country_year.do"
.         *based on: "CINE Data Replication Do File.do"
.         *creates "country_year_mimpute.dta"
. 
. capture log close
